|
|
|
CREATE TABLE
Create a table.
Syntax:
CREATE [GLOBAL TEMPORARY] TABLE [schema.]table (tbl_defs,...)
[ON COMMIT {DELETE|PRESERVE} ROWS]
[storage_options | CLUSTER cluster_name (col1, col2,... )
| ORGANIZATION {HEAP [storage_options] | INDEX idx_organized_tbl_clause}]
[LOB_storage_clause][varray_clause][nested_storage_clause]
partitioning_options
[[NO]CACHE] [[NO]MONITORING] [PARALLEL parallel_clause]
[ENABLE enable_clause | DISABLE disable_clause]
[AS subquery]
tbl_defs:
column datatype [DEFAULT expr] [column_constraint(s)]
table_constraint
table_ref_constraint
storage_options:
PCTFREE int
PCTUSED int
INITTRANS int
MAXTRANS int
STORAGE storage_clause
TABLESPACE tablespace
[LOGGING|NOLOGGING]
idx_organized_tbl_clause:
storage_option(s) [PCTTHRESHOLD int]
[COMPRESS int|NOCOMPRESS]
[ [INCLUDING column_name] OVERFLOW [storage_option(s)] ]
nested_storage_clause:
NESTED TABLE nested_item STORE AS storage_table
[RETURN AS {LOCATOR|VALUE} ]
partitioning_options:
Partition_clause {ENABLE|DISABLE} ROW MOVEMENT
Missing from this page are the options for creating OBJECT TABLES - see the Oracle docs for this.
Examples
create table SIMPLE (MY_NUM number primary key);
create table COPY_OF_EMP as
select * from EMP;
create table EMPTY_COPY as
select * from EMP where 1 = 0;
create table ACCOUNTS(
AC_ID_PK number primary key,
AC_STATUS number,
AC_COUNTRY_ID number default 44,
AC_CREATED date default sysdate,
AC_ACCOUNT varchar2(50)
)
tablespace DATA;
create table SALES(
SA_ID_PK number primary key,
SA_PRODUCT_ID number not null,
SA_DATE_PART date not null,
SA_COST number (12,2) not null
)
partition by range (SA_DATE_PART) (
partition P01_JAN values less than (to_date('2005-02-01','yyyy-mm-dd')),
partition P02_FEB values less than (to_date('2005-03-01','yyyy-mm-dd')),
partition P03_MAR values less than (to_date('2005-04-01','yyyy-mm-dd')),
partition P04_APR values less than (to_date('2005-05-01','yyyy-mm-dd')),
partition P05_REST values less than (maxvalue)
);
"Make everything as simple as possible, but not simpler." - Albert
Einstein
Related Commands:
ALTER INDEX
ALTER VIEW
COMMENT - Add a comment to a table or a column.
Related Views:
V$RESERVED_WORDS DBA_ALL_TABLES ALL_ALL_TABLES USER_ALL_TABLES DBA_TABLES ALL_TABLES USER_TABLES TAB DBA_PART_TABLES ALL_PART_TABLES USER_PART_TABLES