ďť??xml version="1.0" encoding="utf-8" standalone="yes"?>
grant connect,create table to test1;
conn cyts_cc/cyts_cc@orcl2000;
create table(
id int)
tablespace user;
ERROR ä˝äş˝W?1 čĄ?
ORA-01950: 襨犺é?USERS'ä¸ć ćé
conn cyts_cc/cyts_cc@orcl2000;
alter user test1 quota 1M on users;
create tab
(id int);
success
alter user test1 account lock;
conn test1/test1@orcl2000;
ERROR:
ORA-28000: the account is locked
1 Database Schema
 (t¨Šng)a schema is a named collection of objects
 (t¨Šng)b user is created and a corresponding schema is created
 (t¨Šng)c user can be associated only with one schema
 (t¨Šng)d username and schema are often userd interchangely.
2 Checklist for creating users
 (t¨Šng) a idntfigy tablespaces in which the usr nedds to store objects
 (t¨Šng) b decide on quotas for each tablespace
 (t¨Šng) c assign a default tablespace and temporary tablespace.if you do not specify at the time of create user,system tablespace will be the defalut tablespace and temporary.it will affect the performance of the oralce.
 (t¨Šng) d create user
 (t¨Šng) e grant privileges and roles to user
 (t¨Šng) desc dba_users;
 (t¨Šng) select * from dba_users;
3 Creating a new user:
Database Authentiacation
 (t¨Šng)set the initial password
 (t¨Šng) create user aaron
 (t¨Šng) identified by soccer
 (t¨Šng) default tablespace data
 (t¨Šng) temporary tablespace temp
 (t¨Šng) guota 15m on data
 (t¨Šng) password expire;
 (t¨Šng) alter database default temporary tablespace temp;
4 Creating a new user operating System Authentication
 (t¨Šng) os_authent_prefix initialllization parameter specifies the format of the username
 (t¨Šng) defauts to ops$
 (t¨Šng) (t¨Šng) (t¨Šng) create user arron
 (t¨Šng) (t¨Šng) (t¨Šng) identified externally
 (t¨Šng) (t¨Šng) (t¨Šng) default tablespace users
 (t¨Šng) (t¨Šng) (t¨Šng) temporary tablespace temp
 (t¨Šng) (t¨Šng) (t¨Šng) quota 15m on data
 (t¨Šng) (t¨Šng) (t¨Šng) password expire;
 (t¨Šng) (t¨Šng) (t¨Šng) conn /
 (t¨Šng) (t¨Šng) (t¨Šng) show parameter os
 (t¨Šng) (t¨Šng) (t¨Šng) os_authent_prefix (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) string (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) OPS$
 (t¨Šng) (t¨Šng) (t¨Šng) create user ops$test3
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) identified externally
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) default tablespace us
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) temporary tablespace
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) quota 10m on users
 (t¨Šng) (t¨Šng) (t¨Šng) thee test2 is an user of os ,which the oracle is installed.
5 Changing user quota on tablespace
 (t¨Šng)alter user test3 quota 4m on users;
 (t¨Šng)you cann't grant quota on temp and undotbs.
 (t¨Šng)
 (t¨Šng)alter quota 0 on uers -- means that no new table space can be allocated and cannot change the exist object in the tablespaces
6 drop user
 (t¨Šng)you cannot drop user who has connected to oracle
 (t¨Šng) drop user (cascade)
7 Obtaining User information
 (t¨Šng)information about uers can be obtained by qerying the data dictionary
 (t¨Šng) dba_users
 (t¨Šng) ĺç§°Â (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
-----------------------------
USERNAME (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
USER_ID (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
PASSWORD (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
ACCOUNT_STATUS (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
LOCK_DATE (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
EXPIRY_DATE (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
DEFAULT_TABLESPACE (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
TEMPORARY_TABLESPACE (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
CREATED (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
PROFILE (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
INITIAL_RSRC_CONSUMER_GROUP (t¨Šng) (t¨Šng) (t¨Šng)
EXTERNAL_NAME (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
 (t¨Šng) dba_ts_quotas
 (t¨Šng) (t¨Šng) ĺç§°Â (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
 (t¨Šng)---------------
 (t¨Šng)TABLESPACE_NAME
 (t¨Šng)USERNAME (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
 (t¨Šng)BYTES (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
 (t¨Šng)MAX_BYTES (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
 (t¨Šng)BLOCKS (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
 (t¨Šng)MAX_BLOCKS (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
5 set operator guidelines
 (t¨Šng). teh expressions in the select list must match in number and data type;
 (t¨Šng). Parentheses can be used to alter the sequence of the execution
 (t¨Šng).The order by clause:
 (t¨Šng) (t¨Šng) (t¨Šng) can appear only at the very end of the statement
 (t¨Šng) (t¨Šng) (t¨Šng) will accept the column name,aliases from thee firest select statement ,or thee positional notation
 (t¨Šng).Duplicate row are atuomatically eliminated except in union all.
 (t¨Šng).Column names from the first query appear in the result
 (t¨Šng).The output is sorted in ascending order by default except in union all
6 matching the select statement
 (t¨Šng)select department_id,to_number(null),location,hire_date
 (t¨Šng)from employees
 (t¨Šng)union
 (t¨Šng)select department_id,location_id,to_date(null)
 (t¨Šng)from departments;
 (t¨Šng)select employee_id,job_id,salary
 (t¨Šng)from employees
 (t¨Šng)union
 (t¨Šng)select employee_id,job_id,0
 (t¨Šng)from job_history;
7 Controlling the order of the rows
 (t¨Šng)select 'sing' as "my dream" ,3,a_dummy
 (t¨Šng)from dual
 (t¨Šng)union
 (t¨Šng)select 'like''d like to teach',1
 (t¨Šng)from dual
 (t¨Šng)union
 (t¨Šng)select 'the world to',2
 (t¨Šng)from dual
 (t¨Šng)order by 2;
 (t¨Šng)4) 希ć in out ĺć°
 (t¨Šng) create or replace function result
 (t¨Šng) (num1,number,num2 in out nu8mber)
 (t¨Šng) return number
 (t¨Šng) as
 (t¨Šng) (t¨Šng) (t¨Šng) v_result number(6);
 (t¨Šng) (t¨Šng) (t¨Šng) v_remainder number;
 (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) v_result:=num1/num2;
 (t¨Šng) (t¨Šng) (t¨Šng) v_remainder:=mod(num1,num2);
 (t¨Šng) (t¨Šng) (t¨Šng) num2:=v_remainder;
 (t¨Šng) (t¨Šng) (t¨Šng) retrun v_result;
 (t¨Šng) exception
 (t¨Šng) (t¨Šng) (t¨Šng) when zero_divide then
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) raise_application_error(-20000,'zero divied');
 (t¨Šng) end;
 (t¨Šng)5) ĺ˝ć°č°ç¨çéĺ?br /> (t¨Šng) -- ĺ¨sql čŻĺĽä¸ĺŞč˝č°ç¨ĺĺ¨ĺ˝ć?br /> (t¨Šng) -- ĺ¨sql čŻĺĽä¸ĺŞč˝č°ç¨ĺ¸Śćčžĺ
Ľĺć°in ĺQčä¸č˝ćčžĺşĺć°out ĺin out ĺć°çĺ˝ć?br /> (t¨Šng) -- ĺ¨sql čŻĺĽä¸č°ç¨çĺ˝ć°çĺć°ĺż
ĺŔLŻć ĺçsql ć°ćŽžcŐdĺQä¸č˝ćŻpl/sql ćçŇ(gu¨Š)çć°ćŽçąťĺ?br /> (t¨Šng) -- ĺ¨sql čŻĺĽä¸č°ç¨çĺ˝ć°ä¸č˝ĺ
ĺŤinsertĺQupdate ĺdelete
 (t¨Šng)6) ćĽçćşäťŁç ?br /> (t¨Šng) set pagesize 40
 (t¨Šng) select text form user_source where name='result';
 (t¨Šng)7) ĺ é¤ĺ˝ć°
 (t¨Šng) drop function result;
 (t¨Šng)3 ˝Ąçĺç¨ĺş?br /> (t¨Šng) 1) ĺĺşĺ˝ĺç¨ćˇçĺ˝Eĺş
 (t¨Šng) (t¨Šng) select object_name,created,status form user_objects
 (t¨Šng) (t¨Šng) where object_type in ('procedure','function');
 (t¨Šng) 2)ĺĺşĺç¨ĺşćşäťŁç
 (t¨Šng) (t¨Šng) select text from user_sorce where name='raise_salary'
 (t¨Šng) 3)žcŐdşĺç¨ĺşçźčŻéčŻ?br /> (t¨Šng) (t¨Šng) (t¨Šng) -- show errors
 (t¨Šng) (t¨Šng) (t¨Šng) --使ç¨ć°ćŽĺĺ
¸user_errors (t¨Šng) źŽĺŽé误ĺĺ ĺ佞|?br /> (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) select line||'/'||position as "line/col",text error
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) from user_errors where name='raise_salary';
 (t¨Šng) (t¨Šng) 4) ĺĺşĺŻščąĄçäžčľĺ
łžp?br /> (t¨Šng) (t¨Šng) (t¨Šng) -- ä˝żç¨ user_dependenciess źŽĺŽç´ćĽäžčľĺ
łçłť
 (t¨Šng) (t¨Šng) (t¨Šng) select name,type from user_dependencies
 (t¨Šng) (t¨Šng) (t¨Šng) where referenced_name='emp'
 (t¨Šng) (t¨Šng) (t¨Šng) -- ä˝żç¨ deptree ĺ?ideptree źŽĺŽäžčľĺč§č§Łäžčľĺ
łžp?br /> (t¨Šng) (t¨Šng) (t¨Šng) select nested_level,name,type from deptree;
 (t¨Šng) (t¨Šng) 5) éć°ž~čŻĺç¨ĺş?br /> (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ĺ˝č˘Ťĺşç¨ĺŻščąĄççťć袍俎ćšäťĽĺĺQĺ°ąäź?x¨Ź)ĺ°ç¸ĺ
łäžčľĺŻščąĄč˝Źĺä(sh¨´)¸şć ćinvalid ĺQéčŚéć°çźčŻ?br /> (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 1
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) alter table emp add remark varchar2(100);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 2
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) select object_name,object_type from user_objects
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) where status='invalid'
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 3
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) alter procedure add_employee compile;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) alter view dept10 compile;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) alter function get_info compile;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
 (t¨Šng) (t¨Šng)
 (t¨Šng) (t¨Šng) (t¨Šng) end;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) )
 (t¨Šng) (t¨Šng) (t¨Šng) 3) éĺśčĄč§Śĺĺ¨
 (t¨Šng) (t¨Šng) (t¨Šng) ĺ˝äÉç¨čĄč§Śĺĺ¨ďźéťčޤć
ĺľä¸äź(x¨Ź)ĺąćŻä¸Şč˘Ťä˝ç¨čĄä¸ä¸ćä¸ĆĄč§Śĺĺ¨äťŁç ĺQäŘ(f¨´)äş?ji¨Łn)ćśĺžĺçšĺŽćĄägä¸ć§čĄčĄč§Śĺĺ¨äťŁç ďźéčŚäÉç¨when ĺĺĽ
 (t¨Šng) (t¨Šng) (t¨Šng) create or replace trigger tr_sal_change
 (t¨Šng) (t¨Šng) (t¨Šng) after update of sal on emp
 (t¨Šng) (t¨Šng) (t¨Šng) for each row
 (t¨Šng) (t¨Šng) (t¨Šng) when(old.job='salesman')
 (t¨Šng) (t¨Šng) (t¨Šng) declare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) v_temp int..
2 dml č§Śĺĺ¨äÉç¨ćł¨ćäşĺ?br /> (t¨Šng) č§Śĺĺ¨äťŁç ä¸č˝äťč§Śĺĺ¨ć寚ĺşçĺşčĄ¨ä¸čŻŐdć°ćŽ
3 dml č§Śĺĺ?br /> (t¨Šng) ä¸ŢZş(ji¨Łn)äżčŻć°ćŽĺşćťĄłçšĺŽçĺä¸č§ĺćäźä¸éťčžĺQĺŻäťĽäÉç¨çşŚćďźč§Śĺĺ¨ĺĺç¨ĺşă續ćć§č˝ć弽ďźĺŽç°ć˝ĺďźć䝼äŘ(f¨´)ĺŽéďźĺŚćč§Śĺĺ¨ä¸çĺŽçÍźĺŻäťĽéćŠč§Śĺĺ¨ă?br /> (t¨Šng) dml č§Śĺĺ¨ĺŻäťĽç¨äşĺŽç°ć°ćŽĺŽĺ
¨äżć¤ďźć°ćŽĺŽĄčŽĄĺQć°ćŽĺŽć´ć§ďźĺç
§ĺŽć´ć§ďźć°ćŽĺ¤ĺś˝{ĺč˝ă?br /> (t¨Šng)1) ć§ĺść°ćŽĺŽĺ
¨
 (t¨Šng) create or replace trigger tr_emp_time
 (t¨Šng) before insert or update or delete on emp
 (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) if to_char(sysdate,'hh24') not between '9' and '17' then
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) raise_application_error(-20101,'not work time');
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end if;
 (t¨Šng) end;
 (t¨Šng) 2) ĺŽç°ć°ćŽĺŽĄčŽĄ
 (t¨Šng) 使ç¨ć°ćŽĺŽĄčŽĄĺŞč˝ĺŽĄčŽĄsql ćä˝ĺQčä¸äź?x¨Ź)莰载ć°ćŽĺĺ?br /> (t¨Šng) audit insert,update,delete on emp by access
 (t¨Šng) 3)ĺŽç°ć°ćŽĺŽć´ć?br /> (t¨Šng) éŚé續ć?alter table emp add constraint ck_sal check (sal>=800),ä˝ćŻĺ¨ćäşć
ĺľä¸ĺŞč˝ä˝żç¨č§Śĺĺ¨ćĽĺŽç°ć°ćŽĺŽć´ć?br /> (t¨Šng) (t¨Šng) create or replace trigger tr_check sal
 (t¨Šng) (t¨Šng) before update of sal on emp
 (t¨Šng) (t¨Šng) for each row
 (t¨Šng) (t¨Šng) when (new.sla<old.sal or new.sal>1.2* old.sal)
 (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) raise_application_error(,,,,,,)
 (t¨Šng) (t¨Šng) end;
 (t¨Šng) 3) 使ç¨ĺźç¨ĺŽć´ć?br /> (t¨Šng) éç¨ on delete cascade ĺŻäťĽqčĄéčĺ é¤ĺQä˝ćŻĺ´ä¸č˝qčĄéčć´ć°ăéç¨č§Śĺĺ¨ĺŽç°éčć´ć°
 (t¨Šng) (t¨Šng) create or replace trigger tr_update
 (t¨Šng) (t¨Šng) after update of sal on emp
 (t¨Šng) (t¨Šng) for each row
 (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) update emp set depno=:new.deptno where dentno=:old.deptno;
 (t¨Šng) (t¨Šng) end;
4 ĺťşçŤinstead of č§Śĺĺ?br /> (t¨Šng) 寚亽ĺč§ĺ֯䝼ç´ćĽčżčĄinsert update ĺdelete ˝{ćä˝ďźä˝ćŻĺŻšäşĺ¤ćč§ĺžä¸ĺ
莸čżčĄinsertĺQupdate ĺdelete ćä˝ă?br /> (t¨Šng) 来čöä¸ä¸ćĄäťśç为ĺ¤ćč§ĺ?br /> (t¨Šng) (t¨Šng) (t¨Šng) ĺ
ähćä˝éĺ˝W?unionĺQunion all ĺQintersectĺQminus
 (t¨Šng) (t¨Šng) (t¨Šng) ĺ
ähĺçťĺ˝ć° minĺQmaxĺQavgĺQsumĺQcount
 (t¨Šng) (t¨Šng) (t¨Šng) ĺ
ähgroup by connect ž~čŻ ćstart with
 (t¨Šng) (t¨Šng) (t¨Šng) ĺ
ähdistinct
 (t¨Šng) (t¨Šng) (t¨Šng) ĺ
ähqćĽ
 (t¨Šng) ä¸ŢZş(ji¨Łn)ĺ¨ĺ¤ćč§ĺžä¸ć§čĄdml ćä˝ĺQĺż
ĺťčŚĺŢZşinstead-of č§Śĺĺ¨ďźĺťşçŤinsteadĺQof č§Śĺĺ¨ĺĺQĺ°ąĺŻäťĽĺŢZşĺ¤ćč§ĺžć§čĄinsertĺQupdateĺdelete čŻĺĽă?br /> (t¨Šng) (t¨Šng) instead of é饚ĺŞäÉç¨äşč§ĺž
 (t¨Šng) (t¨Šng) ĺŢZşč§ĺžĺťşçŤč§Śĺĺ¨ćśĺQä¸č˝ĺŽäšbefore ĺ?after
 (t¨Šng) (t¨Šng) ĺ¨ĺžçŤč§ĺžćśä¸č˝ćĺŽ with check option
 (t¨Šng) (t¨Šng) ĺ˝ĺžçŤinstead of č§Śĺĺ¨ćśĺQĺż
ĺŔLĺŽfor each row é饚
 (t¨Šng) 1) ĺťşçŤĺ¤ćč§ĺždept_emp
 (t¨Šng) (t¨Šng) create or replace view dept_emp as
 (t¨Šng) (t¨Šng) select a.deptno,a.dname,b,empno,b,ename
 (t¨Šng) (t¨Šng) from dept a,emp b
 (t¨Šng) (t¨Šng) where a,deptno=b.deptno;
 (t¨Šng) 2) ĺťşçŤ insteadĺQof č§Śĺĺ?br /> (t¨Šng) (t¨Šng) create of replacee trigger tr_instead_of_dept_emp
 (t¨Šng) (t¨Šng) instead of insert on dept_emp
 (t¨Šng) (t¨Šng) for each row
 (t¨Šng) (t¨Šng) declare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) v_temp int;
 (t¨Šng) (t¨Šng) beegin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) select count(*) into v_temp from dept where deptno=:new.deptno;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) if v_temp=0 then
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) insert into dept(deptno,dname) values(:new.deptno,:new.dname);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end if;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) select count(*)into v_temp from emp where empno=:new.empno;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) if v_temp=0 then
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) insert into emp(empno,ename,deptno)
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) values(:new.deptno,:new.ename,:new.deptno);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end if;
 (t¨Šng) (t¨Šng) end;
 (t¨Šng) (t¨Šng)
 (t¨Šng) (t¨Šng) ĺŻäťĽĺŻšč§ĺžć§čĄinsert ćä˝äş?br /> (t¨Šng) (t¨Šng) (t¨Šng) insert into dept_emp values(50,'admin','1223','mary')
5 ˝Ąçč§Śĺĺ?br /> (t¨Šng) 1) 楤şč§Śĺĺ¨äżĄć?br /> (t¨Šng) (t¨Šng) (t¨Šng) select trigger_name,status from user_triggers
 (t¨Šng) (t¨Šng) (t¨Šng) where table_name='emp';
 (t¨Šng) (t¨Šng) 2)źć˘č§Śĺĺ?br /> (t¨Šng) (t¨Šng) (t¨Šng) alter trigger tr_check_sal disable;
 (t¨Šng) (t¨Šng) 3) Čzťč§Śĺĺ¨
 (t¨Šng) (t¨Šng) (t¨Šng) alter trigger tr_check_sal enable;
 (t¨Šng) (t¨Šng) 4) źć˘ććżzťčĄ¨ä¸çććč§Śĺĺ¨
 (t¨Šng) (t¨Šng) (t¨Šng) alter table emp disable all triggers;
 (t¨Šng) (t¨Šng) (t¨Šng) alter table emo eanble all triggers; (t¨Šng)
 (t¨Šng) (t¨Šng) 5)éć°ž~čŻč§Śĺĺ?br /> (t¨Šng) (t¨Šng) (t¨Šng) alter trigger tr_check_sal compile;
 (t¨Šng) (t¨Šng) 6) ĺ é¤č§Śĺĺ?br /> (t¨Šng) (t¨Šng) (t¨Šng) drop trigger tr_check_sal;