Index organization table and heap organization table in Oracle

Source: Internet
Author: User

 

 

Create an EMP table:

[SQL] Create Table EMP as select object_id empno, object_name ename, created hiredate, owner job from all_objects affected rows: 53759 time: 4.172 Ms

SQL parsing: query the object_id, object_name, created, and owner fields in the all_object table and rename them to empno, ename, hiredate, and job. The EMP table consists of query results.

Add a primary key for the preceding table:

[SQL] ALTER TABLE EMP add constraint emp_pk primary key (empno) affected rows: 0 time: 0.330 Ms

 

[SQL] Begin dbms_stats.gather_table_stats (user, 'emp', cascade => true); end; affected rows: 1 time: 2.495 Ms

 

 

[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) affected rows: 0 time: 0.047 Ms

 

[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) rows affected by organization index: 0 time: 0.081 Ms

Organization index indicates creating an Iot table

 

 

[SQL] insert into heap_addresses select empno, 'work', '2014 Main Street ', 'Washington', 'DC ', 123 affected rows from EMP: 20123 time: 53759 Ms

 

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;

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.