Oracleϵͳ¹ÜÀíºÍϵͳ×ÊÁÏ»ñÈ¡µÄһЩ»ù±¾ÃüÁî
×ÊÁÏ»ñÈ¡×ÔѧϰºÎÃ÷Öø×÷<<Oracle DBA Åàѵ½Ì³Ì>>µÚ¶þ°æÖ®Ê±.ÆäÖÐdba_¿ªÍ·µÄ±íÐèÒªÓÐsysdbaȨÏÞ²ÅÄÜ·ÃÎÊ.
1. »ñÈ¡Êý¾Ý¿âÃû×Ö,´´½¨ÈÕÆÚ,µ±Ç°Ä£Ê½,ÈÕ־ģʽµÈµÈ:
SELECT name,created,log_mode,open_mode from v$database;
2. »ñÈ¡ÔËÐÐʵÀýµÄÖ÷»úÃû,ʵÀýÃû,°æ±¾:
SELECT host_name,instance_name,version from v$instance;
3. »ñÈ¡×é¼þ°æ±¾ÐÅÏ¢.
SELECT * from v$version;
4.»ñÈ¡¿ØÖÆÎļþÐÅÏ¢.
SELECT * from v$controlfile;
5.»ñÈ¡ÈÕÖ¾ÎļþÐÅÏ¢.
SELECT * from v$logfile;
ºÍ
SELECT group#, members, bytes, status, archived from v$log;
6. »ñÈ¡±¸·ÝºÍ»Ö¸´²ßÂÔ,ÒÔ¼°¹éµµÎļþλÖÃ.(Ò²ÐèÒªsysdbaȨÏÞ)
archived log list
7. Èç¹ûÉÏÃæÊä³öÖеĴ浵ÖÕµãµÄÖµ²»ÊÇÖ±½ÓµÄĿ¼¶øÊÇ USE_DB_RECOVERY_FILE_DEST µÄ»°,ÓÃÒÔÏÂÓï¾ä»ñÈ¡×îÖÕÐÅÏ¢.
SELECT name,value from v$parameter WHERE name = 'db_recovery_file_dest';
8.»ñÈ¡±í¿Õ¼äÐÅÏ¢.
SELECT tablespace_name, block_size, status, contents, logging from dba_tablespaces;
9. »ñÈ¡Êý¾ÝÎļþÐÅÏ¢.
SELECT file_id, file_name, tablespace_name, status, bytes from dba_data_files;
10. ÔÚûÓÐsysdbaȨÏÞʱ,¿ÉÒÔÓÃÒÔÏÂÓï¾äÀ´»ñÈ¡Êý¾ÝÎļþµÄ´¢´æÎ»ÖÃÐÅÏ¢.
SELECT name from v$datafile;
11. »ñÈ¡Óû§ÐÅÏ¢.
SELECT username,created from dba_users;
Ïà¹ØÎĵµ£º
¡¡¡¡decode()º¯ÊýÊÇORACLE PL/SQLÊǹ¦ÄÜÇ¿´óµÄº¯ÊýÖ®Ò»£¬Ä¿Ç°»¹Ö»ÓÐORACLE¹«Ë¾µÄSQLÌṩÁ˴˺¯Êý£¬ÆäËûÊý¾Ý¿â³§É̵ÄSQLʵÏÖ»¹Ã»Óд˹¦ÄÜ¡£
DECODEº¯ÊýÊÇORACLE PL/SQLÊǹ¦ÄÜÇ¿´óµÄº¯ÊýÖ®Ò»£¬Ä¿Ç°»¹Ö»ÓÐORACLE¹«Ë¾µÄSQLÌṩÁ˴˺¯Êý£¬ÆäËûÊý¾Ý¿â³§É̵ÄSQLʵÏÖ»¹Ã»Óд˹¦ÄÜ¡£DECODEÓÐÊ²Ã´Ó ......
ÏÂÃæÊÇÓÃscottÓû§²âÊԵġ£
Èç¹û²»ÖªµÀµ±Ç°Óû§ÊÇʲôÓû§,¿ÉÒÔÊäÈë: show user ,ÕâÑùËü¾ÍÏÔʾ³öµ±Ç°Óû§ÊÇʲôÓû§ÁË.
Èç¹ûÏë±à¼ÒѾÊäÈëµ½sqlplusÖеĴúÂë,¿ÉÒÔÊäÈë“ed”£¬È»ºó»Ø³µ¾ÍÄܵ¯³öÒ»¸ö¼Çʱ¾£¬¼Çʱ¾ÀïÃæÓÐÉÏÒ»²½ÊäÈëµÄ´úÂë,Ð޸ĴúÂë²¢±£´æºó¹Ø±Õ¼Çʱ¾,×îºóÔÚsqlplusÖÐÊäÈë“/”²¢»÷»Ø ......
ROLLUP£¬ÊÇGROUP BY×Ó¾äµÄÒ»ÖÖÀ©Õ¹£¬¿ÉÒÔΪÿ¸ö·Ö×é·µ»ØÐ¡¼Æ¼Ç¼ÒÔ¼°ÎªËùÓзÖ×é·µ»Ø×ܼƼǼ¡£
CUBE£¬Ò²ÊÇGROUP BY×Ó¾äµÄÒ»ÖÖÀ©Õ¹£¬¿ÉÒÔ·µ»ØÃ¿Ò»¸öÁÐ×éºÏµÄС¼Æ¼Ç¼£¬Í¬Ê±ÔÚĩβ¼ÓÉÏ×ܼƼǼ¡£
ÔÚÎÄÕµÄ×îºó¸½ÉÏÁËÏà¹Ø±íºÍ¼Ç¼´´½¨µÄ½Å±¾¡£
1¡¢ÏòROLLUP´«µÝÒ»ÁÐ
SQL> select division_id,sum(salary)
2  ......
±í1£ºtemp1
AA BB CC
1 1 1
1 1 2
1 1 3
±í2£ºtemp2
AA BB ......
//¼ÆËãºÁÃë²î(Á½¸ödateÀàÐ͵ÄÏà¼õΪÌìÊý²î±ð£¬È»ºóת»»ÎªºÁÃë)
select ceil(to_date('209-11-17 13:00:12','yyyy-mm-dd hh24:mi-ss')-to_date(2009-11-18 14:00:12','yyyy-mm-dd hh24:mi-ss') )from dual;
//¼ÆËãÏà²îÔ·Ý
select (EXTRACT(year from to_date('209-11-17','yyyy-mm-dd'))-EXTRACT(year from  ......