国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
create table [Oracle SQL]

create table [Oracle SQL]

Prerequisites

For a user to be able to create a table, he needs the create table system privilege, otherwise he'll receive the ORA-01031: insufficient privileges error message.
Additionally, the user needs to have enough quota on the tablespace where he wants to create the table.

Heap tables

Usually, if we refer to tables, we mean heap tables, although there are other types as well.
A heap table is created like this:
create table t (                a number,                b varchar2(10)                )                
It is possible to create the constraints together with the create statement. As a foreign key references a known type, it is not necessary to specify the foreign key's column type.
create table orders (                order_id   number primary key                order_dt   date,                cust_id    references customers                )                
A primary key needs to have an associated (unique) index. It is possible to specify on what tablespace this index is going to be created:
create table orders (                order_id number,                order_dt date,                cust_id  references customer                constraint pk_orders (order_id) using index tablespace ts_idx                )                

Index organized tables (IOT)

create table iot_ (                a number,                b varchar2(10),                constraint pk_iot_ primary key (a, b)                )                organization index;                

Global temporary tables

The following example shows the difference for redo generated when using global temporary tables and "ordinary" heap tables. It uses the redo_diff package.
create global temporary table gtt_ (                x_ varchar2(100)                ) on commit delete rows;                create table t_ (                x_ varchar2(100)                );                exec redo_diff.diff_it;                declare                i number;                begin                for i in 1 .. 1000 loop                insert into gtt_ values(dbms_random.string('a',99));                end loop;                end;                /                exec redo_diff.diff_it;                declare                i number;                begin                for i in 1 .. 1000 loop                insert into t_ values(dbms_random.string('a',99));                end loop;                end;                /                exec redo_diff.diff_it;                

Organization external

The following create table statement creates an external table.
create table (....)                organization external (                type              oracle_loader                default directory some_dir                access parameters (                records delimited  by newline                fields  terminated by ','                missing field are values null                )                location ('some_file.csv')                )                reject limit unlimited;                

Nested tables

create or replace type item as object (                item_id Number  ( 6  ),                descr   varchar2(30  ),                quant   Number  ( 4,2)                );                /                
create or replace type items as table of item;                /                
create table bag_with_items (                bag_id                   number(7)     primary key,                bag_name                 varchar2(30)  not null,                the_items_in_the_bag     items                )                nested table the_items_in_the_bag store as bag_items_nt;                
Adding a unique constraint for item_id:
alter table bag_items_nt add constraint uq_item_id unique(item_id);                

of XMLType

create table table_name of xmltype;                create table table_name of xmltype XMLSchema "some_url" element "root-element";                create table table_name (columns..., xml_doc) XMLType xmltype column xml_doc element "root-element";                
Creates a table for XML DB.

Create table ... as select

This is one of the few statements that can make use of the nologging option.
In fact, if the database is running noarchive log, the create table .. as select statement is nologging..

Mintrans and Maxtrans

pctfree and pctused

Displaying a tables definition

In SQL*Plus, a table's definition can be displayed with describe. A more verbose (and more complete) output can be optained with dbms_metadata.get_ddl.

create table [Oracle SQL]

Prerequisites

For a user to be able to create a table, he needs the create table system privilege, otherwise he'll receive the ORA-01031: insufficient privileges error message.
Additionally, the user needs to have enough quota on the tablespace where he wants to create the table.

Heap tables

Usually, if we refer to tables, we mean heap tables, although there are other types as well.
A heap table is created like this:
create table t (                    a number,                    b varchar2(10)                    )                    
It is possible to create the constraints together with the create statement. As a foreign key references a known type, it is not necessary to specify the foreign key's column type.
create table orders (                    order_id   number primary key                    order_dt   date,                    cust_id    references customers                    )                    
A primary key needs to have an associated (unique) index. It is possible to specify on what tablespace this index is going to be created:
create table orders (                    order_id number,                    order_dt date,                    cust_id  references customer                    constraint pk_orders (order_id) using index tablespace ts_idx                    )                    

Index organized tables (IOT)

create table iot_ (                    a number,                    b varchar2(10),                    constraint pk_iot_ primary key (a, b)                    )                    organization index;                    

Global temporary tables

The following example shows the difference for redo generated when using global temporary tables and "ordinary" heap tables. It uses the redo_diff package.
create global temporary table gtt_ (                    x_ varchar2(100)                    ) on commit delete rows;                    create table t_ (                    x_ varchar2(100)                    );                    exec redo_diff.diff_it;                    declare                    i number;                    begin                    for i in 1 .. 1000 loop                    insert into gtt_ values(dbms_random.string('a',99));                    end loop;                    end;                    /                    exec redo_diff.diff_it;                    declare                    i number;                    begin                    for i in 1 .. 1000 loop                    insert into t_ values(dbms_random.string('a',99));                    end loop;                    end;                    /                    exec redo_diff.diff_it;                    

Organization external

The following create table statement creates an external table.
create table (....)                    organization external (                    type              oracle_loader                    default directory some_dir                    access parameters (                    records delimited  by newline                    fields  terminated by ','                    missing field are values null                    )                    location ('some_file.csv')                    )                    reject limit unlimited;                    

Nested tables

create or replace type item as object (                    item_id Number  ( 6  ),                    descr   varchar2(30  ),                    quant   Number  ( 4,2)                    );                    /                    
create or replace type items as table of item;                    /                    
create table bag_with_items (                    bag_id                   number(7)     primary key,                    bag_name                 varchar2(30)  not null,                    the_items_in_the_bag     items                    )                    nested table the_items_in_the_bag store as bag_items_nt;                    
Adding a unique constraint for item_id:
alter table bag_items_nt add constraint uq_item_id unique(item_id);                    

of XMLType

create table table_name of xmltype;                    create table table_name of xmltype XMLSchema "some_url" element "root-element";                    create table table_name (columns..., xml_doc) XMLType xmltype column xml_doc element "root-element";                    
Creates a table for XML DB.

Create table ... as select

This is one of the few statements that can make use of the nologging option.
In fact, if the database is running noarchive log, the create table .. as select statement is nologging..

Mintrans and Maxtrans

pctfree and pctused

Displaying a tables definition

In SQL*Plus, a table's definition can be displayed with describe. A more verbose (and more complete) output can be optained with dbms_metadata.get_ddl.
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Access、MSSQL、MYSQL數(shù)據(jù)庫(kù)之間有什么區(qū)別
Oracle常用DDL語(yǔ)句
SQL語(yǔ)句---創(chuàng)建表(約束的用法)
oracle數(shù)據(jù)庫(kù)開(kāi)發(fā)的一些經(jīng)驗(yàn)積累
Oracle 數(shù)據(jù)庫(kù)中的五類(lèi)完整性約束
oracle新手入門(mén)指導(dǎo)之五—ORACLE約束[天源迪科論壇]
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服