ďť??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)
 (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)
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) (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;
 (t¨Šng) (t¨Šng) exec grant_sys_priv('create session','scott');
 (t¨Šng) (t¨Šng) 3 使ç¨execute immediate ĺ¤çdml ćä˝
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 1) ĺ¤çć ĺ ä˝çŹŚĺreturning ĺĺĽçdml čŻĺĽ
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) delcare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat varchar2(100);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat:='update emp set sal=sal*1.1 where deptno=44';
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) execute immediate sql_stat;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 2) ĺ¤çĺ
ĺŤĺ ä˝˝WŚçdmlčŻĺĽ
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) delare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat varchar2(100);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat:='update emp set sql=sql*(1+:percent/100)'
 (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) ||'where deptno=:dno';
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) execute immediate sql_stat using &1,&2;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 3) ĺ¤çĺ
ĺŤreturning ĺĺĽçdmlčŻĺĽ
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) declare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) salary number(6,2);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat varchar2(200);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat:='update emp set sal=sal*(1:percent/100)'
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ||'where empno=:eno returning sal into :salary';
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) execute immediate sql_stat using &1,&2;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) returning into salary;
 (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) čžĺ
Ľ1çĺ?15
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) čžĺ
Ľ2çĺ?2222
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ć°ĺˇĽčľďź2223
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 4) 使ç¨execute immediate ĺ¤çĺčĄćĽčŻ˘
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) declare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat varcchar2(100);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) emp_record emp%rowtype;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat:='select * from emp where empno=:eno';
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) execute immediate sql_stat into emp_record using &1;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end;
 (t¨Šng)3 ĺ¤çĺ¤čĄćĽčŻ˘čŻĺĽ
 (t¨Šng) (t¨Šng) declare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type empcurtyp is ref cursor;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) emp_cv empcurtyp;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) emp record emp%rowtype;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat varchar2(100);
 (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat:='select * from em where deptno=:dno';
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) open emp_cv for sql_stat using &dno;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) loop
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) fetch emp_cu into emp_record;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) exit when emp_cv%notfound;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end loop;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) close emp_cv;
 (t¨Šng) (t¨Šng) end;
4 ĺ¨ĺ¨ćsql ä¸äÉç¨bulkčŻĺĽ
 (t¨Šng) (t¨Šng) 1) ĺ?execute immediate čŻĺĽä¸äÉç¨ĺ¨ćbulk čŻĺĽ
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) declare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type ename_table_type is table of emp.ename%type
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) index by binary_integer;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type sal_table_type is table of emp.sal%type
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) index by binary_integer;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ename_table ename_table_type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sa_table sal_table_type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sal_stat varchar2(100);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat:='update emp set sal=sal*(1+:percent/100)'
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) || 'where deptno=:dno'
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ||'returning ename,sal into :name,:salary';
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) execut immediate sql_stat using &percent,&dno
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) returning bulk collect into ename_table,sal_table;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) for i in 1..ename_table.count loop
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ....
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end loop;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end;
 (t¨Šng) (t¨Šng) (t¨Šng) 2) 使ç¨bulk ĺĺĽĺ¤çĺ¤čĄćĽčŻ˘
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat:='select ename from emp where deptno=:dno';
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) execute immediate sql_stat bulk collect into ename_table using &dno;
 (t¨Šng) (t¨Šng) (t¨Šng) 3) ĺ¨fetch čŻĺĽä¸äÉç¨bulk ĺĺĽ
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) declare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type empcurtyp is ref cursor;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) emp_cv empcurtyp;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type ename_table_type is table of emp.ename%type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) index by binary_integer;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ename_table ename_table_type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat varchar2(100);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat:='select ename from emp where job:=title';
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) open emp_cv for sql_stat using '&job';
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) fetch emp_cv bulk collect into ename_table;
 (t¨Šng) (t¨Šng) (t¨Šng) 4) ĺ¨forall čŻĺĽä¸äÉç¨bulk ĺĺĽ
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) declare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type ename_table_type is table of emp.ename%type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type sla_table_type is table of emp.sal%type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ename_table ename_table_type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sal_table sal_table_type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat varchar2(100);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ename_table:=ename_table_type('scott','smith','clark');
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) sql_stat:='update emp set sal=sal*1.1 where ename=:1'
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ||'returning sal into :2';
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) forall i in 1..ename_table.count
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) execite immediate sql_stat using ename_table(i)
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) returning bulk collect into sal_table; (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng)
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end;
2 Starting Point
 (t¨Šng).Specifies the condition that must be met
 (t¨Šng).Accepts any valid condition
3 Waling the Tree
 (t¨Šng) connect by prior column1=column2
 (t¨Šng) walk from the top donw ,using the employees table
 (t¨Šng) (t¨Šng) top donw
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) column1=parentkey
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) column2=childkey
 (t¨Šng) (t¨Šng) bottom up
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) column1=child key
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) column2=parent key
 (t¨Šng) select level,last_name
 (t¨Šng) from employees
 (t¨Šng) start with last_name='king'
 (t¨Šng) connect by prior employee_id=manager_id;
 (t¨Šng) alter profile profile1 limit
 (t¨Šng) passowrd_lock_time 1/24 (t¨Šng) --one hour
5 passowrd expiration and aging
 (t¨Šng)passwowd_life_time lifetime of the passowrd in days (t¨Šng) after which the password expires(ććć?
 (t¨Šng)password_grace_time grace period in days for changing the password after the first (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) successful login afteer the password has expired(éĺŽć?
 (t¨Šng)e.g
 (t¨Šng)alter profile profile1 limit
 (t¨Šng)password_life_time 2
 (t¨Šng)password_grace_time 3;
6 password history
 (t¨Šng)password_reuse_time:number of days before a passowrd and be resued
 (t¨Šng)password _reuse_max:maxum number of times password can bee reused
 (t¨Šng)e.g
 (t¨Šng)alter profile profile1 limit
 (t¨Šng)password_reuse_time 10
 (t¨Šng)password_reuse_max 3;
7passowrd Verification(study latter)
8drop a profile
 (t¨Šng)drop profile profile1 (cascade);
the user will use the default profile.it will take effect on the new session.
9 Resource Management
 (t¨Šng)Resource mangement limits can be enforced at the session level,the call level or both
 (t¨Šng)limits can be defined by profiles using the create profile command
 (t¨Šng)enable resource limints with the
 (t¨Šng) .resource_limit initialization parameter
 (t¨Šng) (t¨Šng) alter system command
 (t¨Šng)e.g
 (t¨Šng)alter system set resource_limit=true;
10 setting a Resdource limits at session level
 (t¨Šng) cup_per_session : total cpu time measured in hundredths of seconds (çÖäšä¸żU?
 (t¨Šng) sessions_per_user: number of coucurrent sessions allowed for each username
 (t¨Šng) connect_time:elapsed connect time measured in minutes
 (t¨Šng) idle_time :periods of inactive time measured in minutes
 (t¨Šng) logical_reads_per_session: number of data blocks
 (t¨Šng) private_sga :measure in reads
 (t¨Šng) e.g
 (t¨Šng) alter profile profile1 limit
 (t¨Šng) cpu_per_session 100000
 (t¨Šng) connect_time 60
 (t¨Šng) idle_time 5;
 (t¨Šng)
 (t¨Šng) alter user test profile profile1
11 Setting Resource limits at call level (t¨Šng)
 (t¨Šng)e.g
 (t¨Šng)alter profile profile1
 (t¨Šng)cpu_per_call 1000 (t¨Šng) -- cup time per call in
 (t¨Šng)logical_reads_per_call --number of data balock that can be read per call
 (t¨Šng)
 (t¨Šng) create profile develper_prof limit
 (t¨Šng) (t¨Šng) session_per_user2
 (t¨Šng) (t¨Šng) cpu_per_session 10000
 (t¨Šng) (t¨Šng) idle_time 60
 (t¨Šng) (t¨Šng) connect_time 480
12 Managing Resources using database resource manager
 (t¨Šng) (t¨Šng) 1)Provides the oracle server with more control over resorce management decisions
 (t¨Šng) (t¨Šng) 2)elements of database resorcee manager
 (t¨Šng) (t¨Šng) (t¨Šng) resource consumer group
 (t¨Šng) (t¨Šng) (t¨Šng) resourcee plan
 (t¨Šng) (t¨Šng) (t¨Šng) resource allocation method
 (t¨Šng) (t¨Šng) (t¨Šng) resource plan directives
 (t¨Šng) (t¨Šng) 3)dbms_resource_manager package is uerd to create and maintain elements
 (t¨Šng) (t¨Šng) 4)requires administer_resource_manager privilege
 (t¨Šng) (t¨Šng) (t¨Šng) desc dbms_resoource_manager
13 0btaining password and resource limits informaiton
 (t¨Šng) information about password and resource limits can be obtained by querying the data dictonary
 (t¨Šng) (t¨Šng) dba_users
 (t¨Šng) (t¨Šng) select * from users;
 (t¨Šng) (t¨Šng) dba_profiles
 (t¨Šng) (t¨Šng) select * from dba_profiles where profile='PROFILE1'
 (t¨Šng)SQL> create user testuser
 (t¨Šng) 2 (t¨Šng) identified by test;
User created
SQL> conn testuser/test@orcl2000
Not logged on
SQL> grant access session to testuser;
grant access session to testuser
Not logged on
SQL> conn digit_cc/digit_cc@orcl2000
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as digit_cc
SQL> grant create session to testuser;
Grant succeeded
SQL> conn testuser/test@orcl2000;
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as testuser
4 user System privileges
 (t¨Šng)once a user is created,the dba can grant specific system privileges to a user
 (t¨Šng)grant privilege[,privilege...]
 (t¨Šng)to user [,user|role,public...];
 (t¨Šng)DBA can grant a user specific system privileges
 (t¨Šng)grant create session,create table,create sequence,create view (t¨Šng) to scott;
5 creating and granting privileges to role
' Create a role
 (t¨Šng) create role manager;
 (t¨Šng).grant privileges to a role
 (t¨Šng) grant create table,create view to manager
 (t¨Šng).Grant a role to user
 (t¨Šng) grant manager to kochar;
 (t¨Šng)
SQL> create role testrole;
Role created
SQL> grant create table,create view,create sequence to testrole;
Grant succeeded
SQL> grant testrole to testuser;
6 change your password
 (t¨Šng)you can change your password by using the alter user statement;
 (t¨Šng)alter user scott
 (t¨Šng)indetified by lion;
7 object privileges
 (t¨Šng)object privileges vary from object to object
 (t¨Šng)an owner has all the privilege to the object
 (t¨Šng)an owner can give specific privilege on that owner object
 (t¨Šng) grant select on auther to testuser;
 (t¨Šng) grant select on outher to testuser with grant option -- testuser also can grant it to
other user;
 (t¨Šng) grant update(department_name,location_id)
 (t¨Šng) on departments
 (t¨Šng) to scott,manager;
8 how to revoke object privileges
 (t¨Šng)--you use the revoke statement to revoke privileges granted to other users
 (t¨Šng)--privileges granted to other users through the with grant option clause are also revoked.
 (t¨Šng) revoke privilege {[,privilege...]|all} on object
 (t¨Šng) from {user[,user....]|role|public}
 (t¨Šng) [cascade constraints]
 (t¨Šng) revoke select on author from user;
9 Database Links
 (t¨Šng)Database link allow user to access data in the remote database;
SQL> create database link kjw1
 (t¨Šng) 2 (t¨Šng) connect to digit_cc identified by digit_cc
 (t¨Šng) 3 (t¨Šng) using 'orcl2000';
Database link created
SQL> select * from digit_cc.table_action@kjw1;
ĺ¨ä¸ä¸Şĺĺ¸ĺźççŻĺ˘éĺQć°ćŽĺşéžćĽćŻĺŽäšĺ°ĺ śĺŽć°ćŽĺşç衯ĺžçä¸ä¸ŞéčŚćšćłďźä˝żĺžqç¨ĺ¤ç夊襣ć çźă?/p>
čŚčˇĺžć°ćŽĺşéžćĽçć´ćˇąĺĽĽççĽčŻďźćĽçOracle8i SQL ReferenceĺQOracle8i SQLĺčďź(j¨Ş)ĺOracle8i Concepts ĺQOracle8ićŚĺżľćĺĺQă诌žlčľćçĺŚä¸ä¸Şć弽çćĽćşćŻOracle8i Distributed Database SystemsĺQOracle8iĺĺ¸ĺźć°ćŽĺşžpČťćĺĺQă?/p>
äťĺ¤Ščޏĺ¤qčĄOracleçćşććä¸ć˘ä¸ä¸ŞOracleć°ćŽĺşăććśä¸˝Ąĺ莥ĺćŻĺŚqć ˇĺQä¸ä¸Şć°ćŽĺşä¸çć°ćŽĺŻč˝ä¸ĺŚä¸ć°ćŽĺşä¸çć°ćŽĺ łčăĺşç°čżżUć ĺ|śĺQä˝ ĺŻäťĽéžćĽq两个ć°ćŽĺşä˝żĺžç¨ćˇćĺşç¨ç¨ĺşĺŻäťĽčŽżéŽććć°ćŽďźŽąĺĽ˝čąĄĺŽäťŹĺ¨ä¸ä¸Şć°ćŽĺşä¸ăĺ˝ä˝ čżäšĺćÓźä˝ ĺ°ąćäş(ji¨Łn)ä¸ä¸Şĺĺ¸ĺźć°ćŽĺşçłťžlă?
ĺŚä˝Žä¸¤ä¸Şć°ćŽĺşéžćĽĺ¨ä¸čľˇĺ˘ĺQäÉç¨ä¸ä¸Şć°ćŽĺşéžćĽćĽĺŽćăć°ćŽĺşéžćĽćŻĺŽäšä¸ä¸Şć°ćŽĺşĺ°ĺŚä¸ä¸Şć°ćŽĺşçčľ\ĺžç寚蹥ăć°ćŽĺşéžćĽĺ čŽ¸ä˝ ćĽčŻ˘čż˝E襨ĺ?qi¨˘ng)ć§čĄčż˝Eç¨ĺşăĺ¨äťÖM˝ĺĺ¸ĺźçŻĺ˘éĺQć°ćŽĺşéžćĽé˝ćŻĺż čŚçă?
˝ĺćĄäž?/p>
ć°ćŽĺşéžćĽççŽçćŻĺŽäšä¸ćĄĺ°qç¨ć°ćŽĺşç衯ĺžĺQäÉä˝ ĺŻäťĽéčżĺ¨ćŹĺ°ć§čĄä¸ćĄSQLčŻĺĽćĽäÉç¨éŁä¸Şć°ćŽĺşä¸ç襨ĺĺ śĺŽç寚蹥ăäžĺŚďźä˝ ĺ¨ä¸ä¸Şčż˝Eć°ćŽĺşä¸ćä¸ä¸Şç§°äšäŘ(f¨´)"geographic feature name"ç襨ĺQčä˝ ć_¨ĺˇ˛čżćĽĺ°ä˝ ćŹĺ°ć°ćŽĺşçć ĺľä¸čŽKŽéŁäşć°ćŽăć°ćŽĺşéžćĽćŁćŻä˝ ćéčŚçăĺ¨ĺťşçŤĺŽäšĺďźä˝ ĺż ĺŔLéĺŚä¸äżĄćŻďź(x¨Ź)
ä¸ä¸Şç˝žlćĺĄĺżUÍźä˝ çćŹĺ°ć°ćŽĺşäşäžč˝ĺ¤äÉç¨ĺŽćĽä¸qç¨äşäžç¸čżćĽčż˝Eć°ćŽĺşä¸çććç¨ćˇĺĺĺŁä×o(h¨´)ž|çťćĺĄĺç§°ćŻćŻä¸ä¸Şć°ćŽĺşéžćĽĺż éçăćŻä¸ĆĄä˝ äťĺŽ˘ćähşPC使ç¨SQL*PlusqćĽĺîC˝ çć°ćŽĺşć˝čŚäÉç¨ćĺĄĺżU°ăĺ¨éŁäşć ĺľä¸ďźä˝ ćäžçťSQL*Plusç罞lćĺĄĺżU°ćŻéčżĺ¨ä˝ ç厢ćähşä¸çnsnames.oraćägä¸ćĽć֎䝏ćĽč§Łćçăĺ¨ć°ćŽĺşéžćĽä¸ä˝żç¨ç罞lćĺĄĺżUîCšćŻĺŚć¤ďźé¤éćŻéŁäşĺĺćŻä˝żç¨éŠČĺ¨ćĺĄĺ¨ä¸çtnsnames.oraćägćĽč§Łćă?
ĺ¨ä˝ ĺŽäšć°ćŽĺşéžćĽćśćĺŽçç¨ćˇĺĺĺŁäť¤ďźç¨äşĺťşçŤä¸čż˝EäşäžçqćĽăä¸éźŹçźç ç¨ćˇĺĺĺŁäť¤ďźĺťşçŤć°ćŽĺşéžćĽäšćŻĺŻč˝ççčłćŻĺźĺžéĺçăć˘çśčżć řPźç°ĺ¨ć䝏注ćq个ćç´ćĽçäžĺă?
ä¸ĺčŻĺĽĺťşçŤäş?ji¨Łn)ä¸ä¸Şć°ćŽĺşéžćĽĺQĺŽĺ 莸čŽKŽĺŽ˘ćˇĺ¸ćˇĺQčżä¸Şĺ¸ćähŻäşĺ ĺ¨GNISć°ćŽĺşĺžĺĽ˝çĺQ?/p>
CREATE DATABASE LINK GNIS
CONNECT TO GUEST IDENTIFIED BY WELCOME
USING 'GNIS';
éžćĽĺç§°GNISç´§éLINKĺ łéŽĺăĺ˝qćĽĺ°čż˝EäşäžćśĺQCONNECT TO...IDENTIFIEDĺĺĽćĺŽUEST/WELCOMEä˝äŘ(f¨´)ç¨ćˇĺĺĺŁä×o(h¨´)ä˝żç¨ ăUSINGĺĺĽćĺŽéčżž|çťćĺĄĺç§°GNISĺťşçŤqćĽăäÉç¨čżä¸éžćĽĺQç°ĺ¨ä˝ ĺŻäťĽĺ¨čż˝Eć°ćŽĺşä¸ćĽčŻ˘ć°ćŽăäžĺŚďź(x¨Ź)
SQL> SELECT GFN_FEATURE_NAME
2 FROM GNIS.FEATURE_NAMES@GNIS
3 WHERE GFN_FEATURE_TYPE='falls'
4 AND GFN_STATE_ABBR='MI'
5 AND GFN_COUNTY_NAME='Alger';
GFN_FEATURE_NAME
_________________
Alger Falls
Au Train Falls
Chapel Falls
Miners Falls
Mosquito Falls
Tannery Falls
..
ĺ¨SELECTčŻĺĽä¸@GNISç´§é襨ĺżU͟说ćGNIS.FEATURE_NAMES襨ćŻĺ¨čż˝Eć°ćŽĺşĺQĺşčŻĽéčżGNISéžćĽčŽKŽĺQéžćĽçąťĺOraclećŻćĺ ç§ä¸ĺžcŐdçéžćĽăčżäşçąťĺç¸äşéĺ ďźććśéžäťĽéčżé饚qčĄĺçąťăĺ˝ä˝ ĺžçŤć°ćŽĺşéžćĽćÓźä˝ éčŚäťä¸é˘éĺĺQ?
PublicĺQĺ Źç¨ďź(j¨Ş)ćPrivate ĺQç§ćďź(j¨Ş)éžćĽ
ćéžc? Fixed UserĺQĺşĺŽç¨ćřPź(j¨Ş), Connected UserĺQčżćĽç¨ćřPź(j¨Ş)ć?Current UserĺQĺ˝ĺç¨ćřPź(j¨Ş)
Shared LinkĺQĺ
ąäşŤéžćĽďź(j¨Ş)ć?Not Shared LinkĺQéĺ
×ínéžćĽĺQ?
ćŻćŹĄĺĺžć°ćŽĺşéžćĽćśĺQä˝ čŚčŞč§ä¸čŞč§ĺ°ĺq丿UéćŠă?
ĺ
Źç¨éžćĽä¸ç§ćéžćĽç¸ĺŻŇ(gu¨Š)Ż
ĺ Źç¨ć°ćŽĺşéžćĽĺŻšććçć°ćŽĺşç¨ćˇĺźćžčŽżéŽćăĺé˘ćž˝CşçćŻç§ćć°ćŽĺşéžćĽĺQĺŽĺŞĺŻšĺťşçŤĺŽçç¨ćˇććăĺ Źç¨ć°ćŽĺşéžćĽć´äŘ(f¨´)ćç¨ĺQĺ 为ĺŽä˝żä˝ ä¸ĺż 为ćŻä¸ä¸Şć˝ĺ¨ç¨ćˇĺĺťşĺçŹçéžćĽăäŘ(f¨´)äş?ji¨Łn)ĺžçŤä¸ä¸Şĺ Źç¨ć°ćŽĺşéžćĽĺQäÉç¨ĺŚä¸ćž˝CşçPUBLICĺ łéŽĺďź(x¨Ź)
CREATE PUBLIC DATABASE LINK GNIS
CONNECT TO GUEST IDENTIFIED BY WELCOME
USING 'GNIS';
ĺłäÉqćŻä¸ä¸Şĺ Źç¨éžćĽďźç¨ćˇĺäťć§ĺşĺŽăććäÉç¨čżä¸ŞéžćĽçç¨ćˇé˝ä˝ä¸şç¨ćˇGUESTqćĽĺ°čż˝Eć°ćŽĺşă?
使ç¨ć°ćŽĺşéžćĽčŽżéŽčż˝E襨
ĺ? ć°ćŽĺşéžćĽGNISĺQćć罞lćĺĄĺżUÍźéžćĽPRODäşäžĺ°GNISäşäžä¸çFEATURE_NAMES襨ă?
ćéžc?/p>
ĺ˝ä˝ ĺťşçŤä¸ä¸Şć°ćŽĺşéžćĽćÓźĺ łäşä˝ ĺŚä˝ćć寚qç¨ć°ćŽĺşčżčĄčŽżéŽďźć丿UéćŠăčżä¸ç§éćŠäťŁčĄ¨äş?ji¨Łn)ć°ćŽĺşéžćĽçĺŚä¸żUĺžcŔLšćłăčżä¸ç§žcŐdŤĺŚä¸ĺQ?
ĺşĺŽç¨ćˇăäŘ(f¨´)qç¨ć°ćŽĺşéžćĽćĺŽç¨ćˇĺĺĺŁäť¤ďźä˝äŘ(f¨´)ć°ćŽĺşéžćĽĺŽäšçä¸é¨ĺă?
qćĽç¨ćˇăĺ¨ä¸ćĺŽç¨ćˇĺĺĺŁäť¤ćśĺĺžçć°ćŽĺşéžćĽă?
ĺ˝ĺç¨ćˇăĺžçŤć°ćŽĺşéžćĽňqśćĺŽCURRENT_USERĺ
łéŽĺă?
ĺşĺŽç¨ćˇć°ćŽĺşéžćĽćŻćĺ¨ĺĺžéžćĽćśäŘ(f¨´)qç¨ć°ćŽĺşćĺŽç¨ćˇĺĺĺŁäť¤ăčżä¸éžćĽä¸çŽĄäťäšćśĺäÉç¨ďźäšć čŽř°ä˝żç¨ĺQé˝ä˝żç¨ç¸ĺçç¨ćˇĺĺĺŁäť¤çťéĺ°qç¨ć°ćŽĺşăĺ°çŽĺ为ć˘ä˝ ĺ¨ćŹćä¸ćçĺ°çé˝ćŻĺşĺŽç¨ćˇéžćĽă?
ĺşĺŽç¨ćˇéžćĽĺQĺ°¤ĺ śćŻĺ Źç¨ĺşĺŽç¨ćˇéžćĽçä¸ä¸Şć˝ĺ¨éŽććŻäťäťŹćčż˝Eçłťžlä¸çĺä¸ĺ¸ćˇžläş(ji¨Łn)莸ĺ¤ćŹĺ°ç¨ćˇăäťĺŽĺ ¨č§ĺşŚćĽčŻ´ĺQĺŚćććçćŹĺ°ç¨ćˇĺ¨čż˝Eçłťžlä¸ćĽćĺä¸ä¸Şĺ¸ćřPźč´ŁäQŽŢpŚćä(sh¨´)¸ĺQčżĺĺłäşç¨ćďL(f¨Ľng)ć°é ăĺŚćć°ćŽä¸˘ĺ¤ąďźĺ äšä¸ĺŻč˝çĄŽĺŽç ´ĺćŻĺŚä˝ĺççăĺŚä¸ä¸Şć˝ĺ¨éŽé˘ćŻĺ Źç¨ĺşĺŽç¨ćˇéžćĽŽĺŻšqç¨ć°ćŽĺşçčŽKŽćçťäş?ji¨Łn)ććçćŹĺ°ć°ćŽĺşç¨ć÷?
ĺŚćä˝ ä¸ć_¨ć°ćŽĺşéžćĽä¸ĺľĺ Ľç¨ćˇĺĺĺŁä×o(h¨´)ĺQOraclećäžžlä˝ ĺŚä¸ä¸Şé常ćç¨çéćŠăä˝ ĺŻäťĽĺťşçŤä¸ä¸ŞčżćĽç¨ćˇéžćĽăčżćĽç¨ćˇéžćĽćŻqć ˇçéžćĽďźĺŽéčżäťÖM¸ä¸ŞćŁĺ¨äÉç¨čŻĽéžćĽçćŹĺ°ć°ćŽĺşçç¨ćďL(f¨Ľng)ç¨ćˇĺĺĺŁä×o(h¨´)çťéĺ°čż˝Eć°ćŽĺşăä˝ ĺŻäťĽéčż˝ĺĺ°˝Işĺşç¨ćˇĺĺĺŁä×o(h¨´)ćĽĺžçŤä¸ä¸ŞčżćĽç¨ćˇéžćĽăččĺŚä¸ĺŽäšĺQ?
CREATE PUBLIC DATABASE LINK GNIS
USING 'GNIS';
éžćĽĺćŻGNISăĺŽqćĽĺ°čż˝Eć°ćŽĺşqćĽćśäÉç¨çž|çťćĺĄĺç§°ćŻGNISĺQä˝ćŻć˛ĄććĺŽç¨ćˇĺĺĺŁäť¤ăĺ˝ä˝ ĺ¨ćĽčŻ˘ä¸äÉç¨čżä¸ŞéžćĽćśĺQĺŽ?y¨u)Žĺqç¨ć°ćŽĺşĺéä˝ ĺ˝ĺçç¨ćˇĺĺĺŁäť¤ăäžĺŚďźĺŚćä˝ äÉç¨AHMAD/SECRET çťéĺîC˝ çćŹĺ°ć°ćŽĺşĺQéŁäšAHMAD/SECRETŽćŻä˝ çťéĺ°qç¨ć°ćŽĺşćśä˝żç¨çç¨ćˇĺĺĺŁäť¤ă?
ä¸ŢZş(ji¨Łn)使ç¨ä¸ä¸ŞčżćĽç¨ćˇéžćĽďźä˝ ĺż ĺŐd¨qç¨ć°ćŽĺşä¸ćä¸ä¸Şĺ¸ĺřPźäş?ji¨Łn)č§Łqä¸çŇ(gu¨Š)ŻĺžéčŚçăä¸ä˝čżć řPźčä¸ä˝ ĺ¨ä¸¤ä¸Şć°ćŽĺşä¸ĺşäÉç¨ĺć ďL(f¨Ľng)ç¨ćˇĺĺŁäť¤ăĺŚććŹĺ°çťéäÉç¨AHMAD/SECRETĺQéŁäšçťéĺ°qç¨ć°ćŽĺşćśäšĺż ĺÖMÉç¨ĺć ďL(f¨Ľng)ç¨ćˇĺĺĺŁä×o(h¨´)ăäÉç¨čżćĽç¨ćˇéžćĽćśĺQĺŚćä˝ çĺŁäť¤ä¸ĺďźä˝ ĺ°ąć ćçťéă?
ĺ Źç¨qćĽç¨ćˇć°ćŽĺşéžćĽĺ°¤ĺ śćç¨ďźĺ äŘ(f¨´)ä˝ ĺŻäťĽĺžçŤä¸ä¸ŞĺŻč˘Ťććç¨ćŻŽżéŽçéžćĽĺQĺĆä¸ććç¨ćŻ˘ŤĺĺŤä˝żç¨äťć弚čŞĺˇŢqç¨ćˇĺĺĺŁä×o(h¨´)ććăä˝ čˇĺžč´ŁäQćw˘çĺŠçďźć˛ĄćŽčż˝Eć°ćŽĺşĺä˝ çćŹĺ°ć°ćŽĺşä¸çćŻä¸ä˝ç¨ćˇĺźćžă䝣äťähŻä˝ ĺż ĺŐd¨ä¸¤ä¸Şć°ćŽĺşä¸ĺťşçŤç¨ćˇĺ¸ćˇĺQĺĆä¸ä˝ ĺż éźŽäżĄĺŁä×o(h¨´)äżćä¸č´ă?
ĺ˝ĺç¨ćˇéžćĽéčżä˝żç¨CURRENT_USERĺ łéŽĺĺžçŤĺĆä¸ä¸qćĽç¨ćˇéžćĽçćźźăĺŞćĺ˝ä˝żç¨Oracle Advanced Security OptionĺQOracleéŤçńĺŽĺ ¨é饚ĺQćśĺQä˝ ćč˝ä˝żç¨ĺ˝ĺç¨ćˇéžćĽĺQčżä¸ŞéžćĽĺŞĺŻŇ(gu¨Š)ćäÉç¨X.509莤čŻçç¨ćähç¨ă?
ĺ
×ínéžćĽ
ĺ
×ínć°ćŽĺşéžćĽćŻć诼éžćĽçĺ¤ä¸Şç¨ćˇĺŻäťĽĺ
ąäşŤĺä¸ä¸Şĺşĺąç˝žlčżćĽăäžĺŚďźĺ¨ćĺä˝ç¨ćˇçMTSĺQ夞Użç¨ćĺĄĺ¨ďź(j¨Ş)çŻĺ˘ä¸ďźćŻä¸ä¸Şĺ
ąäşŤćĺĄĺ¨qç¨é˝ĺ°ä¸čż˝EćĺĄĺ¨ćä¸ä¸ŞçŠçéžćĽďźqĺä˝ç¨ćˇĺ
ąäşŤčżä¸¤ä¸ŞéžćĽă?
襨é˘ä¸ďźĺ
×ínéžćĽäšä¸ĺŹčvćĽĺćŻä¸äťśĺĽ˝äşăĺ¨ćäşçŻĺ˘ä¸çźŽĺŚć¤ďźä˝ćŻĺQĺ˝ä˝ čč使ç¨ĺ
×ínéžćĽćÓźĺşĺ˝ćčŻĺ°čżć莸ĺ¤ĺąéć§ĺčŚĺĺQ?
ĺŚćä˝ äÉç¨ä¸ä¸Şä¸ç¨çćĺĄĺ¨čżćĽćĽqćĽĺîC˝ çćŹĺ°ć°ćŽĺşĺQéžćĽĺŞč˝ĺ¨ä˝ äťéŁäşqćĽä¸ĺĺťşçĺ¤éäź?x¨Ź)čŻé´ĺ
ąäşŤă?ĺ¨MTSçŻĺ˘éďźćŻä¸ä¸Şĺ
ąäşŤćĺĄĺ¨qç¨ć˝ĺ¨ĺ°ćĺźä¸ä¸ŞéžćĽăććçäź?x¨Ź)čŻč˘Ťĺä¸ĺ
×ínćĺĄĺ¨čż˝EćäžĺĆä¸ĺ亍袍éŁä¸Şqç¨ćĺźçäQćĺ
ąäşŤéžćĽăĺ 为ĺ¨MTSçŻĺ˘éçä¸ä¸Şĺ
ąäşŤćĺĄĺ¨qç¨č˝ĺ¤ćĺĄäşčޏĺ¤ç¨ćŻżćĽďźĺ
×ínéžćĽçäÉç¨ĺŻč˝ĺŻźč´ćĺźçéžćĽčżĺ¤äşćĺż
饝çéžćĽăç¨SHAREDĺ
łéŽĺĺžçŤĺ
ąäşŤć°ćŽĺşéžćĽăčżĺż
饝使ç¨AUTHENTICATED BY ĺĺĽĺ¨čż˝Eçłťžlä¸ćĺŽä¸ććçç¨ćˇĺĺĺŁäť¤ăĺŚä¸ĺ˝äť¤ĺžçŤä¸ä¸Şĺ
ąäşŤçăĺ
Źç¨çăčżćĽç¨ćäh°ćŽĺşéžćĽĺQ?
CREATE SHARED PUBLIC DATABASE LINK GNIS
AUTHENTICATED BY DUMMY_USER IDENTIFIED BY SECRET
USING 'GNIS';
čŚčˇĺžĺĺťşéžćĽĺ˝Ąçĺĺ¸ĺźçłťžlçć´ĺ¤čľćĺQ诡ćĽé
Oracle Technology Network (http://otn.oracle.com/)ă?
使ç¨AUTHENTICATED BYĺ弽E垎ćäşĺ°ć°ĺQä˝ćŻçąäşĺŽç°ĺ
ąäşŤéžćĽçćšĺźĺŽĺ
¨ć§ĺłĺŽĺŽćŻĺż
ĺČăčżä¸Şäžĺä¸çç¨ćˇĺĺĺŁäť¤DUMMY_USER/SECRETĺż
饝ĺ¨čż˝Eçłťžlä¸ććăçśčďźq稞pČťä¸äÉç¨çĺ¸ćˇäťĺ°ąćŻčżćĽç¨ćďL(f¨Ľng)ĺ¸ćˇăĺŚćć䝼JEFF/SECRETçťéĺ°ćçćŹĺ°ć°ćŽĺşňqśäÉç¨ćĺĺžĺĽ˝çĺ
×ínéžćĽĺQĺ°äź?x¨Ź)ĺç䝼ä¸ä¸žpŐdäşägĺQ?
ä¸ŢZş(ji¨Łn)ćĺźéžćĽĺQOracle使ç¨DUMMY_USER/SECRETĺčż˝Eć°ćŽĺşććă?çśĺĺQOraclečŻĺžä˝żç¨HMAD/SECRET使ćçťéĺ°čż˝Eć°ćŽĺşăĺ
ąäşŤéžćĽç丝čŚçŽçćŻĺŽä¸¤ä¸Şć°ćŽĺşćĺĄĺ¨äšé´çĺşĺąž|çťqćĽć°éăĺŽäťŹćéĺäşMTSçŻĺ˘ĺQĺ¨éŁä˝ ćĽć大éçéčżqä¸éžćĽčŽKŽqç¨ć°ćŽĺşçç¨ćˇăč§ĺżľä¸ĺQä˝ ćŽŠç¨ćˇć°é
čżĺ
×ínćĺĄĺ¨čż˝Eçć°éăéŁäšä˝ ĺŻäťĽéčżä¸şćŻä¸ĺ
×ínćĺĄĺ¨čż˝Ećĺźä¸ä¸ŞéžćĽčä¸ćŻćŻä˝ç¨ćähĺźä¸ä¸ŞéžćĽçćŇ(gu¨Š)łĺQčçčľćşă?
ćĽćžĺ
łäşć°ćŽĺşéžćĽçčľć
ä˝ ĺŻäťĽäťĺ 个ć°ćŽĺĺ ¸č§ĺžä¸čˇĺžĺžçŤĺĽ˝çć°ćŽĺşéžćĽçčľćăDBA_DB_LINKSč§ĺžä¸şćŻä¸ĺŽäšçéžćĽčżĺä¸čĄăOWNER ĺĺDB_LINKĺĺĺŤćž˝CŢZş(ji¨Łn)qä¸éžćĽçććč ĺ(qi¨˘ng)ĺç§°ăĺŻšĺ Źç¨ć°ćŽĺşéžćĽďźOWNERĺĺ°ĺ ĺŤ'PUBLIC'ăĺŚćä˝ ĺťşçŤĺşĺŽç¨ćˇéžćĽĺQç¨ćˇĺĺşĺ¨DBA_DB_LINKSč§ĺžçUSERNAMEĺéĺQä˝ćŻĺŁäť¤ĺŞč˝äťSYS.LINK$č§ĺžä¸çĺ°ăéťčޤć ĺľä¸ĺQĺŞćĺ ˇćSELECT ANY TABLEžpČťćéçDBAč˝ĺ¤čŽKŽSYS.LINK$č§ĺžćĽçĺŁä×o(h¨´)ăä˝ ĺşčŻĽäżć¤čŽKŽéŁä¸Şč§ĺžçćéăALL_DB_LINKS č§ĺžĺ?USER_DB_LINKSč§ĺžä¸?DBA_DB_LINKSč§ĺžç¸çąťäź?ĺŽäťŹĺĺŤćĄ¤şäş?ji¨Łn)ä˝ č˝ĺ¤čŽKŽçććéžćĽĺ(qi¨˘ng)ä˝ ććĽćçĺ ¨é¨éžćĽăćĺďźV$DBLINKĺ¨ćć§č˝č§ĺžĺä˝ ćĄ¤şĺŢZQćçťĺŽćśé´ä˝ -ĺ˝ĺç¨ćˇĺQćĺźçĺ ¨é¨ć°ćŽĺşéžćĽă?
ĺ
¨ĺąć§çć°ćŽĺşĺżU?
ĺ¨ĺĺ¸ĺźçŻĺ˘éďźOracleĺťřŽŽä˝ çć°ćŽĺşéžćĽĺĺşä¸ĺŽäťŹqćĽĺ°çć°ćŽĺşçĺ
¨ĺąć§ĺżU°ç¸ĺw
ăĺ ć¤ĺŚćä˝ ćŁĺ¨qćĽĺ°ĺżUîCŘ(f¨´)GNIS.GENNICK.ORGçć°ćŽĺşĺQä˝ ĺşĺ˝Žä˝ çć°ćŽĺşéžćĽĺ˝ĺ为GNIS.GENNICK.ORG
为祎ĺŽć°ćŽĺşçĺ
¨ĺąć§ĺżU͟䝼SYSTEMçťéňqśćĽčŻ˘GLOBAL_NAMEč§ĺžĺQ?
SQL> SELECT * FROM GLOBAL_NAME;
GLOBAL_NAME
_______________
GNIS.GENNICK.ORG
ç׺ĺĺ˛çĺĺ ďźéťčޤć ĺľä¸ďźĺ ¨ĺąć§ĺżUîC¸ć°ćŽĺşéžćĽĺżU°çäšé´çéžćĽä¸ćŻĺźşĺść§çăä¸qďźä˝ ĺŻäťĽéčżčŽĄ˝ŽGLOBAL_NAMESçĺĺ§ĺĺć°ä¸şTRUEćĽćšĺčżä¸čĄäŘ(f¨´)ăäžĺŚďź(x¨Ź)
SQL> SHOW PARAMETER GLOBAL_NAMES
NAME TYPE VALUE
________________________________________________________
global_names boolean TRUE
ç¨äşäş§çq个čäžçäşäžčŚćąä˝ 使ç¨çć°ćŽĺşéžćĽĺďźĺż 饝ä¸çŽć ć°ćŽĺşçĺ ¨ĺąć§ć°ćŽĺşĺç§°ç¸ĺšé ă注ćä¸ä¸äşOracleć楣ä¸čŻ´çç¸ĺďźĺ łéŽćŻä˝ çćŹĺîCşäžçGLOBAL_NAMES莥˝ŽăĺŚćä˝ çćŹĺîCşäžä¸GLOBAL_NAMES=FALSEĺQä˝ ŽŢp˝ĺ¤äÉç¨ć°ćŽĺşéžćĽĺQčä¸ç¨çŽĄĺŽäťŹćŻĺŚä¸čż˝Eć°ćŽĺşçĺ ¨ĺąć§ĺżU°ç¸ĺw ăćČćĽčŻ´ĺQĺŚćä˝ čŽĄ˝ŽGLOBAL_NAMES=TRUEĺQä˝ ĺşčŻĽĺ¨ä˝ çććäşäžä¸ä¸ĺžčżäšĺă?br />
 (t¨Šng) (t¨Šng) create sequence dept_deptin_seq
 (t¨Šng) (t¨Šng) increment by 10
 (t¨Šng) (t¨Šng) start with 120
 (t¨Šng) (t¨Šng) maxvalue 9999
 (t¨Šng) (t¨Šng) nocache
 (t¨Šng) (t¨Šng) nocycle
 (t¨Šng) 2) Confirming Sequences
 (t¨Šng) (t¨Šng) verify your sequence values in the user_sequences data dictionary table
 (t¨Šng) (t¨Šng) select sequence_name,min_value,max_value,increment_by,last_number
 (t¨Šng) (t¨Šng) from user_sequences;
 (t¨Šng) (t¨Šng) the last_number display the next available sequence number if nocache is specified
 (t¨Šng) 3)nextval and currval Pseudocolumns
 (t¨Šng) (t¨Šng) (t¨Šng) --nextval return thee next available sequence value,it return a unique value every time
it si referenced,even for different ueer;
 (t¨Šng) (t¨Šng) (t¨Šng) --currval obtains the current sequence value;
 (t¨Šng) (t¨Šng) (t¨Šng) --nextval must be issued for that sequence before curval contains a value;
 (t¨Šng) 4) Using a Sequence
 (t¨Šng) (t¨Šng) (t¨Šng) -- Caching sequence values in the memory give faster access to these values;
 (t¨Šng) (t¨Šng) (t¨Šng) -- Gaps in sequence value can occur when
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) a rollback occurs
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) b the system crashes
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) c A sequence us used in another table;
 (t¨Šng) (t¨Šng) 5) alter sequence test increment by 10;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) you can change all properties of the sequence except the start with .
 (t¨Šng) (t¨Šng) 6) remove sequence
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) drop sequence test;
2 index
 (t¨Šng) 1) how are indexes created
 (t¨Šng) (t¨Šng) Automatically : a unique index is created automatically when you create primary key or
unique constraint in a table definition,
 (t¨Šng) (t¨Šng) Manually: user can create nounique index on column to speed up access to the rows.
 (t¨Šng) (t¨Šng) create index testindex on autoer(lanme);
 (t¨Šng) 2) When to Create an index
 (t¨Šng) (t¨Šng) ypu should create an index if:
 (t¨Šng) (t¨Šng) . a column contains a wide range of values
 (t¨Šng) (t¨Šng) . a column contains a large number of null values
 (t¨Šng) (t¨Šng) . one or more columns are frequently used together in where clause or a join condition;
 (t¨Šng) (t¨Šng) . The table is large and most queries are expected to retrieve less than 2 to 4 percent
of the rows;
 (t¨Šng) (t¨Šng) 3) When not to create an index
 (t¨Šng) (t¨Šng) this usually not worth creating an index if:
 (t¨Šng) (t¨Šng) . the table is small
 (t¨Šng) (t¨Šng) . The columns are not often used as a condition in the query.
 (t¨Šng) (t¨Šng) . Most queries are expected to retrieve more than 2 to 4 percent of the rows in the
table
 (t¨Šng) (t¨Šng) . the indexed columns are referenced as part of an expression.
 (t¨Šng) (t¨Šng) 4)Confirming indexes
 (t¨Šng) (t¨Šng) (t¨Šng) . The user_indexes data dictionary view contains the name of the index and tis uniquess
 (t¨Šng) (t¨Šng) (t¨Šng) . the user_ind_columns view contains the index name,the table name,and the column name.
 (t¨Šng) (t¨Šng) (t¨Šng) select ic.index_name,ic_column_name,ic.column_position,ic_col_pos,ix.uniqueness
 (t¨Šng) (t¨Šng) (t¨Šng) from user_indexed ix,user_ind_columns ic
 (t¨Šng) (t¨Šng) (t¨Šng) where ic.index_name=ix.index_name
 (t¨Šng) (t¨Šng) (t¨Šng) and ic.table_name='employees';
 (t¨Šng) 5)ĺŢZşĺ˝ć°ççŚ(ch¨ł)ĺź?br /> (t¨Šng) . a function-based index is an index based on expressions
 (t¨Šng) . The index expression is built form table columns,constraints,SQL functions and user-
defined functions
 (t¨Šng) (t¨Šng) create index testindex2
 (t¨Šng) (t¨Šng) on autors (upper(au_fname));
 (t¨Šng) (t¨Šng)
 (t¨Šng) (t¨Šng) select * from authors
 (t¨Šng) (t¨Šng) where upper(au_fname) like 'B%';
 (t¨Šng) 6) remoe index
 (t¨Šng) (t¨Šng) drop index index_name;
3 synonyms
 (t¨Šng) Simplify access to objects by creating a synonym
 (t¨Šng) (t¨Šng) . Ease referring to a table ownerd by anther user
 (t¨Šng) (t¨Šng) . Shorten lengthy object names;
 (t¨Šng) (t¨Šng) create [publi] synonym synonym for object;
column name;
 (t¨Šng) (t¨Šng) create or replace view empvu80
 (t¨Šng) (t¨Šng) (id_number,name,sal,department_id)
 (t¨Šng) (t¨Šng) as select employee_id,first_name||" "||last_name,salary.department_id
 (t¨Šng) (t¨Šng) from employees
 (t¨Šng) (t¨Šng) where department_id=80;
 (t¨Šng) (t¨Šng) column aliases in the create view clause are listed in the same order as the columns in
the subquery
 (t¨Šng) (t¨Šng) note : alter view_name is not a valid command.
4 Create a Complex View
 (t¨Šng) Create a complex view that contains group functions to display values from two tables
 (t¨Šng) create view dept_sum_vu
 (t¨Šng) (t¨Šng) (name,minsal,maxsal,avgsal)
 (t¨Šng) as
 (t¨Šng) (t¨Šng) select d.department_name,min(e.salary),max(e.salary),avg(e.salary)
 (t¨Šng) (t¨Šng) from employees e,departments d
 (t¨Šng) (t¨Šng) where e.department_id=d.department_id
 (t¨Šng) (t¨Šng) group by d.department_name;
5 Rules for performs DML operaton on a view
 (t¨Šng) 1) You can perform DML operation on simple views
 (t¨Šng) 2) You can not romove a row if the view contains the following:
 (t¨Šng) (t¨Šng) (t¨Šng) --group functions
 (t¨Šng) (t¨Šng) (t¨Šng) --a group by clause
 (t¨Šng) (t¨Šng) (t¨Šng) --the distince keyword
 (t¨Šng) (t¨Šng) (t¨Šng) -- rownum keyword
 (t¨Šng) (t¨Šng) (t¨Šng) -- column defined by expressions
6 Using the with check option Clause
 (t¨Šng) 1) you can ensure that dml operatons performed on the view stay within the domain of the
view by using the with check option clause.
 (t¨Šng) creaate view test1
 (t¨Šng) as
 (t¨Šng) select * from emp where qty>10;
 (t¨Šng) with check option;
 (t¨Šng) update testview1 set qty=10
 (t¨Šng) where ster_id=6830;
 (t¨Šng) --when you doing the following update operation
 (t¨Šng) update testview1 set qty=5 where id=10;
 (t¨Šng) -- an error will report
 (t¨Šng) --you violate the where clause
 (t¨Šng) 2)Any attempt to change the department number for any row in the view fails because it
violates the with check option constraint
 (t¨Šng) (t¨Šng) create or replace view empvu20
 (t¨Šng) (t¨Šng) as
 (t¨Šng) (t¨Šng) select * where department_id=20
 (t¨Šng) (t¨Šng) with check option constriant empvu20_ck;
7 Denying DML Operations
 (t¨Šng) 1 You can ensure that no dml operations occur by adding the with read only option to your
view definition.
 (t¨Šng) 2)Any attempt to a DML on any row in the view resuls in an oralce server error.
8 remove veiw
 (t¨Šng) drop view_name
9 inline view
 (t¨Šng) 1) an inline view is a subquery with an alias that you can use within a sql statement.
 (t¨Šng) 2) a named subquery in the from clause of the main query is an exqmple of an inline view
 (t¨Šng) 3) an inline view is not a schema object.
10 Top-N Analysis
 (t¨Šng)1)Top_N querise ask for the n largest or smallest values of a column.
 (t¨Šng)2)Both largest values and smallest values sets considered Top-N queries
 (t¨Šng) select * from (select ster_id,qty from sales);
 (t¨Šng)example
 (t¨Šng) To display the top three earner names and salaries from the employees
 (t¨Šng) select rownum as rank,last_name,salary
 (t¨Šng) from (select last_anme,slary from employee
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) order by slary desc)
 (t¨Šng) where rownum<=3;
 (t¨Šng)
collection
 (t¨Šng) (t¨Šng) delcare
 (t¨Šng) (t¨Šng) (t¨Šng) type name_varray_type is varray(4) of varchar2(10);
 (t¨Šng) (t¨Šng) (t¨Šng) name_array1 name_varray_type;
 (t¨Šng) (t¨Šng) (t¨Šng) name_array2 name_varray_type;
 (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) name_array1:=name_varray_type('scott','smith');
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) name_array2:=name_array_type('a','b','c');
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) name_array1:=name_array2; (t¨Šng) (t¨Šng)
 (t¨Šng) (t¨Šng) end;
 (t¨Šng) (t¨Šng)
 (t¨Šng)
 (t¨Šng) type name_array1_type is varray(4) of varchar2(10);
 (t¨Šng) type name_array2_type is varray(4) of varchar2(10);
 (t¨Šng) name_array1 name_array1_type;
 (t¨Šng) name_array2 name_array2_type;
 (t¨Šng) ĺ
ähç¸ĺçć°ćŽçąťĺďźĺĺ
ˇćä¸ĺçéĺžcŐdä¸č˝ćčľĺ?br /> (t¨Šng) 2) žléĺčľĺnull ĺ?br /> (t¨Šng) (t¨Šng) (t¨Šng) ĺŻäťĽä˝żç¨delete ć?trim
 (t¨Šng) (t¨Šng) (t¨Šng) äšĺŻäťĽäÉç?˝IşéĺčľžlçŽčĄ¨éĺ?br /> (t¨Šng) (t¨Šng) (t¨Šng) type name_varray_type is varray(4) of varchar2(10);
 (t¨Šng) (t¨Šng) (t¨Šng) name_array name_varray_type;
 (t¨Šng) (t¨Šng) (t¨Šng) name_empty name_varray_type;
 (t¨Šng) (t¨Šng) (t¨Šng)
 (t¨Šng) (t¨Šng) (t¨Šng) name_array:=name_varray_type('1','2');
 (t¨Šng) (t¨Šng) (t¨Šng) name_array:=name_empty;
 (t¨Šng) 3) 使ç¨éĺćä˝čľĺćŻčžéĺé˝ćŻ10g çĺ
厚ďźp176 ĺ
çĽqă?br />4 ćwžlĺŽ
 (t¨Šng) ć§čĄĺčŻsql ćä˝č˝äź éććéĺĺ
ç´ çć°ćŽă?br /> (t¨Šng) 1 forall čŻĺĽ
 (t¨Šng) ç¨äşinsert update ĺdeletećä˝ăĺ¨oracle9i ä¸forall čŻĺĽĺż
饝ĺ
ähqçŽ(hu¨¤)çĺ
ç´?br /> (t¨Šng) (t¨Šng) (t¨Šng) 1) using forall on insert
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) declare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type id_table_type is table of number(6)
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) index by binary_integer;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type name_table_type is table of varchar2(2)
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) index by binary integer;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) id_table id_table_type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) name_table name_table_type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) for i in 1..10 loop
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) id_table(i):=i;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) name_table(i):='Name'||to_char(i);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end loop;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) forall i in 1..id_table.count
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) insert into demo demo values(id_table(i),name_table(i));
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 2)using forall on using update
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) forall i in 1..id_table.count
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) upate demo set name:=name_table(i)
 (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) where id:=id_table(i);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 3)using forall on using delete
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) forall i in 1..id_table.count
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) delete from demo where id:=id_table(i);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 4) using forall on part of the collection
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) for i in1..10 loop
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) id_table(i):=i;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) name_table(i):="name"||to_char(i);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end loop;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) forall i in 8..10 l
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) insert into demo values(id_table(i),name_table(i));
 (t¨Šng) (t¨Šng) 2 bulk collect
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) is fit for select into ,fetch into and dml clause
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 1) using bulk collect
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) declares (t¨Šng) (t¨Šng)
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type emp_table_type is table of emp%rowtype
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) index by binary_integer;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) emp_table emp_table_type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) select * bulk collect into emp_table
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) from emp where deptno=&no;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) for i in 1..emp_tablee.count loop
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) dbms_output.put_line(emp_table(i).ename);
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end loop;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) 2) ĺ¨dml çčżĺĺĺĽäÉç¨bulk collect ĺĺĽ
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) declare
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) type ename_table_type is table of emp.ename%type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) ename_table ename_table_type;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) begin
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) deletee from emp where deptno=&no
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) returning ename bulk_collect into ename_table;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) for i in 1..ename_table.count loop
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) dbms_output.put(ename_table(i));
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end loop;
 (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) (t¨Šng) (t¨Šng) end;
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) end;
parent table is deleted
 (t¨Šng) (t¨Šng) (t¨Šng) on delete set null:Convert the dependent foreign key values to null when a row in the
 (t¨Šng) (t¨Šng) (t¨Šng) parent table is deleted.
 (t¨Šng) (t¨Šng)
 (t¨Šng) (t¨Šng) (t¨Šng) --parent table referenced table
 (t¨Šng) (t¨Šng) (t¨Šng) --child table refernce other table
6 The check Constraint
 (t¨Šng) Define a condition that each row must be satify
 (t¨Šng) alter table test3
 (t¨Šng) add constrain ch_test3 check(name like 's%')
7 Dropping a Constraint
 (t¨Šng) 1) Remove the manager constraint form the employee table
 (t¨Šng) (t¨Šng) alter table test3
 (t¨Šng) (t¨Šng) drop constriant test3_manager_fk
 (t¨Šng) 2) Remove the primary key constraint on the departments table and drop the associated
 (t¨Šng) (t¨Šng) foreign key constraint on the employees.department_id column
 (t¨Šng) (t¨Šng) alter table departments
 (t¨Šng) (t¨Šng) drop primary key cascade
8 Disabling and enable Constraints
 (t¨Šng) 1)Execute the disable clause of the alter table statment to deactive an integrity
constraint
 (t¨Šng) 2)Apply the cascade option to disable dependent integrity constrints
 (t¨Šng) alter table employees
 (t¨Šng) disable constraint emp_emp_id_pl cascade
 (t¨Šng) 3) enabling Constraints
 (t¨Šng) .Active an integrity constraint currently disabled in the table definition by using the
enable clause.
 (t¨Šng) (t¨Šng) alter table employees
 (t¨Šng) (t¨Šng) enable constraint emp_emp_id_pk;
 (t¨Šng) a unique (t¨Šng) or a primary (t¨Šng) index is automatically created if you enable a unique key or a
primary key constraint (t¨Šng)
 (t¨Šng)8 View Constraints
 (t¨Šng) select constraint_name,constriant_type,serch_condition
 (t¨Šng) from user_constraints
 (t¨Šng) where table_name='employees'
 (t¨Šng)9 view the columns associated with constraints
 (t¨Šng)select constraint_name,column_name
 (t¨Šng)from user_cons_columns
 (t¨Šng)where table_name='employees'
 (t¨Šng) select employee_id
 (t¨Šng) from employees
 (t¨Šng) where salary<all
 (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) (select salary
 (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) from employees
 (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) where job_id='ddd')
 (t¨Šng) (t¨Šng) select emp.last_name
 (t¨Šng) (t¨Šng) from employees emp
 (t¨Šng) (t¨Šng) where emp.employee_id not in
 (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) (t¨Šng) (t¨Šng) (t¨Šng) (select mgr.manager_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) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) from employees mgr)
 (t¨Šng) select last_namek,job_id,salary,
 (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) (t¨Šng) decode(job_id,'it' ,1*salary,
 (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) 'manager',1.2*salary,
 (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) salary)
 (t¨Šng) (t¨Šng) from employees
 (t¨Šng) (t¨Šng)
 (t¨Šng)select count(*) from
 (t¨Šng)select count(address) from authors
 (t¨Šng)count the valid count of the address (exclude the null value)
 (t¨Šng)2) Using theDISTINCT Keyword
 (t¨Šng) count(distinct expr) return thee number of the distinct non-null value of the expr
 (t¨Šng) select count(distincee department_id) from employees
 (t¨Šng)3)Group functions and null values
 (t¨Šng) group functions ignore null values in the clumn
 (t¨Šng)4) Using thee NVL Function with Group Functions
 (t¨Šng) The nul function force group funtion to include null values
 (t¨Šng) select avg(nvl(commission_pct,0)) from employees
2 Creating Groups of Data
 (t¨Šng) 1)
 (t¨Šng) a Divide rows in a table into smaller groups by using the group by clause
 (t¨Šng) b All coulmns in the select list that are not in group function must be in the group by clause
 (t¨Šng) select department_id,avg(salary)
 (t¨Šng) from employees
 (t¨Šng) group by department_id;
 (t¨Šng) 2) Grouping by More Than One Column
 (t¨Šng) 3) Ilegal Queries Using Group Functions
 (t¨Šng) (t¨Šng) a You cannot use thee where clause to restrict groups
 (t¨Šng) (t¨Šng) b You use thee having clause to restrict groups
 (t¨Šng) (t¨Šng) c you cannot use group functions in the where clause
 (t¨Šng) 4)Excluding Group Resdults:The Having Clause
 (t¨Šng) (t¨Šng) Use the HAVING clause to restrict groups
 (t¨Šng) (t¨Šng) a Rows are grouped
 (t¨Šng) (t¨Šng) b The group functions is applied
 (t¨Šng) (t¨Šng) c Groups matcching the Having clause are display
 (t¨Šng) select department_id,max(salary)
 (t¨Šng) from employees
 (t¨Šng) group by department_id
 (t¨Šng) having max(salary)>10000
 (t¨Šng)5) Nesting Group function
 (t¨Šng)select max(avg(salary))
 (t¨Šng)from employees
 (t¨Šng)group by department_id;