oracle中的索引組織表與堆組織表

來源:互聯網
上載者:User

 

 

建立一個emp表:

[SQL] create table emp     as     select object_id   empno,            object_name ename,            created     hiredate,            owner       job       from all_objects     受影響的行: 53759時間: 4.172ms

sql解析:查詢all_object表中的object_id,object_name,created和owner欄位,並將其重新命名為empno,ename,hiredate和job,有查詢結果組成emp表。

為上述表添加主鍵:

[SQL] alter table emp add constraint emp_pk primary key(empno)    受影響的行: 0時間: 0.330ms

 

[SQL] begin dbms_stats.gather_table_stats(user,'EMP',cascade=>true);end;受影響的行: 1時間: 2.495ms

 

 

[SQL] create table heap_addresses     ( empno     references emp(empno) on delete cascade,       addr_type varchar2(10),       street    varchar2(20),       city      varchar2(20),       state     varchar2(2),       zip       number,       primary key (empno,addr_type)     )    受影響的行: 0時間: 0.047ms

 

[SQL] create table iot_addresses     ( empno     references emp(empno) on delete cascade,       addr_type varchar2(10),       street    varchar2(20),       city      varchar2(20),       state     varchar2(2),       zip       number,       primary key (empno,addr_type)     )    ORGANIZATION INDEX    受影響的行: 0時間: 0.081ms

ORGANIZATION INDEX表示建立IOT表

 

 

[SQL] insert into heap_addresses select empno, 'WORK', '123 main street', 'Washington', 'DC', 20123 from emp受影響的行: 53759時間: 0.633ms

 

insert into iot_addresses     select empno, 'WORK', '123 main street', 'Washington', 'DC', 20123       from emp

 

begin dbms_stats.gather_table_stats(user,'HEAP_ADDRESSES');end;begin dbms_stats.gather_table_stats(user,'IOT_ADDRESSES');end;

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.