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

ÓÅ»¯select count(*) (תoracleÅàѵÀÏʦµÄÎÄÕÂ)


select count(*) from t1;
Õâ¾ä»°±È½Ï¼òµ¥£¬µ«ºÜÓÐÐþ»ú£¡¶ÔÕâ¾ä»°ÔËÐеÄÀí½â£¬·´Ó³ÁËÄã¶ÔÊý¾Ý¿âµÄÀí½âÉî¶È£¡
½¨Á¢ÊµÑéµÄ´ó±íËût1
SQL> conn scott/tiger
ÒÑÁ¬½Ó¡£
SQL> drop table t1 purge;
±íÒÑɾ³ý¡£
SQL> create table t1 as select * from emp where 0=9;
±íÒÑ´´½¨¡£
SQL> insert into t1 select * from emp;
ÒÑ´´½¨14ÐС£
SQL>  insert into t1 select * from t1;
ÒÑ´´½¨14ÐС£
SQL> /
ÒÑ´´½¨28ÐС£
SQL> /
ÒÑ´´½¨56ÐС£
SQL> /
ÒÑ´´½¨112ÐС£
SQL> /
ÒÑ´´½¨224ÐС£
SQL> /
ÒÑ´´½¨448ÐС£
SQL> /
ÒÑ´´½¨896ÐС£
SQL> /
ÒÑ´´½¨1792ÐС£
SQL> /
ÒÑ´´½¨3584ÐС£
SQL> /
ÒÑ´´½¨7168ÐС£
SQL> /
ÒÑ´´½¨14336ÐС£
SQL> /
ÒÑ´´½¨28672ÐС£
SQL> /
ÒÑ´´½¨57344ÐС£
SQL> commit;
Ìá½»Íê³É¡£
ÊÕ¼¯Í³¼ÆÐÅÏ¢
SQL> execute dbms_stats.gather_table_stats('SCOTT','T1');
PL/SQL ¹ý³ÌÒѳɹ¦Íê³É¡£
SQL> SET AUTOT TRACE EXP
SQL> SELECT COUNT(*) from T1;
Ö´Ðмƻ®
--------------------------------------------------                               
| Id  | Operation          | Name | Rows  | Cost (%CPU)| Time     |                                
-------------------------------------------------------------------                                
|   0 | SELECT STATEMENT   |      |     1 |   124 (4)| 00:00:02 |                  


Ïà¹ØÎĵµ£º

Oracleɾ³ý±íÖÐÖظ´¼Ç¼

--刪³ýÖØ復ÁÐ  
  a.Èç¹ûÓÐID×ֶΣ¬¾ÍÊǾßÓÐΨһÐÔµÄ×ֶΠ 
   
  delect   table   where   id   not   in   (  
   
  select   max(id)   from   table   group   by   col1,col ......

Oracle¹éµµÃüÁתÔØ£©

Ê×ÏȲ鿴Êý¾Ý¿âÏÖÓÐģʽ¿ÉʹÓÃÒÔÏÂÓï¾ä
select name,log_mode from v$database;
Ò²¿ÉÒÔÓÃÏÂÃæµÄÓï¾ä
archive log list£»(¸Ã·½·¨ÐèÒªas sysdba)
¶ÔÓڷǹ鵵ģʽµÄÊý¾Ý¿â¸ÃΪ¹éµµÄ£Ê½£¨Ö÷ÒªÒÔOracle 10gΪ²Î¿¼£©Ê¹ÓÃÒÔϲ½Ö裺
1. SQL> alter system set log_archive_dest_1='location=/oracle/oracle10g/log/archive ......

Oracle°´×Ö·û½ØÈ¡×Ö·û´®º¯Êý

ÊäÈë²ÎÊý£ºstr ——Òª½ØÈ¡µÄ×Ö·û´®,  ch——Òª²éÕÒµÄ×Ö·û´®
½ØÈ¡ch֮ǰ£¨²»°üÀ¨ch£©µÄ×Ö·û´®£º substr(str, 0, instr(str, ch) - 1)
½ØÈ¡chÖ®ºó£¨²»°üÀ¨ch£©µÄ×Ö·û´®£º substr(str, , instr(str, ch) + 1, length(str)) ......

oracleÈÕÆÚº¯Êý¼¯½õ


Ò»¡¢ ³£ÓÃÈÕÆÚÊý¾Ý¸ñʽ
1.Y»òYY»òYYY ÄêµÄ×îºóһ룬Á½Î»»òÈýλ
SQL> Select to_char(sysdate,'Y') from dual;
TO_CHAR(SYSDATE,'Y')
--------------------
7
SQL> Select to_char(sysdate,'YY') from dual;
TO_CHAR(SYSDATE,'YY')
---------------------
07
SQL> Select to_char(sysdate,'YYY') from ......

ORACLE ×óÓÒÁ´½Ó

Êý¾Ý±íµÄÁ¬½ÓÓÐ:
1¡¢ÄÚÁ¬½Ó(×ÔÈ»Á¬½Ó): Ö»ÓÐÁ½¸ö±íÏàÆ¥ÅäµÄÐвÅÄÜÔÚ½á¹û¼¯ÖгöÏÖ
2¡¢ÍâÁ¬½Ó: °üÀ¨
     £¨1£©×óÍâÁ¬½Ó(×ó±ßµÄ±í²»¼ÓÏÞÖÆ)
     £¨2£©ÓÒÍâÁ¬½Ó(ÓÒ±ßµÄ±í²»¼ÓÏÞÖÆ)
     £¨3£©È«ÍâÁ¬½Ó(×óÓÒÁ½±í¶¼²»¼ÓÏÞÖÆ)
3¡¢×ÔÁ¬½Ó(Á¬½Ó·¢ÉúÔÚÒ»Õ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ