Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

oracle ±Ê¼Ç III Ö®´æ´¢¹ý³ÌÓ뺯Êý

DML(Manipulation):Êý¾Ý²Ù×÷ÓïÑÔ
CRUD
DDL(Definition): Êý¾Ý¶¨ÒåÓïÑÔ,Óë±í£¬Ë÷Òý£¬Í¬Òå´ÊÓйØ
create,alter,drop,rename,truncate(Çå¿Õ)
DCL(Control): Êý¾Ý¿ØÖÆÓïÑÔ£¬ÓëȨÏÞÓйØ
grant,revoke
TCL(Transaction Control): ÊÂÎñ¿ØÖÆÓïÑÔ,ÓëÊÂÎñÓйØ
commit,rollback,savepoint
==========================
´æ´¢¹ý³ÌºÍ´æ´¢º¯Êý£¬Ïàµ±ÖØÒª£¬ÔÚjavaÐèÒªµ÷Óô洢¹ý³ÌºÍº¯Êý
дһ¸öÀý×Ó£ºÐ´Ò»¸öº¯ÊýÍê³ÉÈçϹ¦ÄÜ£¬ÊäÈëÁ½¸ödepartment_id,dept_1,dept_2,·µ»ØËûÃÇÆ½¾ù¹¤×ʽϸߵÄÄǸö²¿ÃÅÖÐ manager µÄsalary
º¯Êý°æ:
create or replace function get_mgr(
 dept_id_1 employess.department_id%type,
 dept_id_2 employees.department_id%type,
 )
 return number
 is
       max_sal_1 employees.salary%type;
       max_sal_2 employees.salary%type;
       dept_id employees.department_id%type;
       mgr_id employees.manager_id%type;
       sal employees.salary%type;
begin
      select max(salary) into max_sal_1  from employees
      where department_id = dept_id_1;
      select max(salary) into max_sal_2  from employees
      where department_id = dept_id_2;
      if max_sal_1 > max_sal_2 then
         dept_id := dept_id_1;
      else
          dept_id := dept_id_2;
      end if;
      select manager_id into mgr_id from departments where department_id = dept_id;
      select salary into sal from employees where employee_id = mgr_id;
       return sal;
end;
sql°æ:
µÚÒ»²½ ²éѯ¸ø¶¨µÄÁ½¸ö²¿ÃÅÖÐ¸ßµÄÆ½¾ù¹¤×Ê:30,80
select max(avg_sal)
from (select avg(salary) avg_sal from emplo


Ïà¹ØÎĵµ£º

oracle ³£ÓòéѯÃüÁî

 Êý¾Ý×Öµädict×ÜÊÇÊôÓÚOracleÓû§sysµÄ¡£
1¡¢Óû§£º
¡¡select username from dba_users;
¸Ä¿ÚÁî
¡¡alter user spgroup identified by spgtest;
2¡¢±í¿Õ¼ä£º
¡¡select * from dba_data_files;
¡¡select * from dba_tablespaces;//±í¿Õ¼ä
¡¡select tablespace_name,sum(bytes), sum(blocks)
from dba_ ......

ÔÚOracleÖвéѯ±íµÄ´óСºÍ±í¿Õ¼äµÄ´óС

 ÓÐÁ½ÖÖº¬ÒåµÄ±í´óС¡£Ò»ÖÖÊÇ·ÖÅä¸øÒ»¸ö±íµÄÎïÀí¿Õ¼äÊýÁ¿£¬¶ø²»¹Ü¿Õ¼äÊÇ·ñ±»Ê¹Ó᣿ÉÒÔÕâÑù²éѯ»ñµÃ×Ö½ÚÊý£º
select segment_name, bytes
from user_segments
where segment_type = 'TABLE';
»òÕß
   Select Segment_Name,Sum(bytes)/1024/1024 from User_Extents Group By Segment_Name
ÁíÒ»ÖÖ±íÊ ......

oracleÖе¥¼Ç¼º¯ÊýµÄ¹éÄÉ×ܽá

 SQLÖеĵ¥¼Ç¼º¯Êý
Ò»¡¢×Ö·ûº¯Êý
 
1.ASCII
·µ»ØÓëÖ¸¶¨µÄ×Ö·û¶ÔÓ¦µÄÊ®½øÖÆÊý;
SQL> select ascii(’A’) A,ascii(’a’) a,ascii(’0’) zero,ascii(’ ’) space from dual;
A A ZERO SPACE
--------- --------- --------- ---------
65 97 48 32
......

Oracle¼ÆËãʱ¼ä²î±í´ïʽ

--»ñÈ¡Á½Ê±¼äµÄÏà²îºÀÃëÊý
select ceil((To_date('2008-05-02 00:00:00' , 'yyyy-mm-dd hh24-mi-ss') - To_date('2008-04-30 23:59:59' , 'yyyy-mm-dd hh24-mi-ss')) * 24 * 60 * 60 * 1000) Ïà²îºÀÃëÊý from DUAL;
/*
Ïà²îºÀÃëÊý
----------
  86401000
1 row selected
*/
--»ñÈ¡Á½Ê±¼äµÄÏà²îÃëÊý
select ce ......

oracleϵͳ±í´óÈ«

Êý¾Ý×Öµädict×ÜÊÇÊôÓÚOracleÓû§sysµÄ¡£
¡¡¡¡1¡¢Óû§£º
¡¡¡¡¡¡select username from dba_users;
¡¡¡¡¸Ä¿ÚÁî
¡¡¡¡¡¡alter user spgroup identified by spgtest;
¡¡¡¡2¡¢±í¿Õ¼ä£º
¡¡¡¡¡¡select * from dba_data_files;
¡¡¡¡¡¡select * from dba_tablespaces;//±í¿Õ¼ä
¡¡¡¡¡¡select tablespace_name,sum(bytes), sum(b ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ