1. 程式人生 > >Oracle Sql 高階程式設計學習過程記錄

Oracle Sql 高階程式設計學習過程記錄

sqlplus工具使用:

 

 

SQL>help index

 @             COPY         PAUSE                    SHUTDOWN

 @@            DEFINE       PRINT                    SPOOL

 /             DEL          PROMPT                   SQLPLUS

 ACCEPT        DESCRIBE     QUIT                     START

 APPEND        DISCONNECT   RECOVER                  STARTUP

 ARCHIVE LOG   EDIT         REMARK                   STORE

 ATTRIBUTE     EXECUTE      REPFOOTER                TIMING

 BREAK         EXIT         REPHEADER                TTITLE

 BTITLE        GET          RESERVED WORDS (SQL)     UNDEFINE

 CHANGE        HELP         RESERVED WORDS (PL/SQL)  VARIABLE

 CLEAR         HOST         RUN                      WHENEVER OSERROR

 COLUMN        INPUT        SAVE                     WHENEVER SQLERROR

 COMPUTE       LIST         SET                      XQUERY

 CONNECT       PASSWORD     SHOW

 

 

 

2016-06-23

程式碼清單3-1

create table scott.t1 as

select trunc((rownum - 1) / 100) id,

           rpad(rownum,100) t_pad

from dba_source

where rownum <= 10000;

 

create index t1_idx1 on t1(id);

exec dbms_stats.gather_table_stats(user,'t1',method_opt=>'FOR ALL COLUMNS SIZE 1',cascade=>true);

 

drop table t2;

create table scott.t2 as

select mod(rownum,100) id,

           rpad(rownum,100) t_pad

from dba_source

where rownum <=10000;

 

create index t2_idx1 on t2(id);

exec dbms_stats.gather_table_stats(user,'t2',method_opt=>'FOR ALL COLUMNS SIZE 1',cascade=>true);

 

select count(*) ct from t1 where id = 1 ;

select count(*) ct from t2 where id = 1 ;

 

select table_name,num_rows,blocks from user_tables where table_name = 'T2';