Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle CREATE TABLE Statement      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: CREATE_TABLE

Definition:
The CREATE TABLE statement is used to create a new table in the database.

Tables are defined in part by the columns they contain. Each column has a specific data type which specifies how data is stored in the column. When creating a new table, you must decide what the appropriate column type should be (CHAR, NCHAR, VARCHAR2, LONG, etc) . These data types are then specified in the CREATE TABLE Statement. In addition, when tables are created they may be assigned additional characteristics, such as INDEXes, auto-incrementing columns, primary keys, constraints, and so on. These additional characteristics can be specified when the table is created or added, modified, or removed after the table has been made.

Example Syntax:

CREATE TABLE "name_of_table"
("column_1" "data_type",
"column_2" "data_type",
"column_3" "data_type",
... )


Example Syntax With Primary Key:

CREATE TABLE "name_of_table"
("column_1" "data_type",
"column_2" "data_type",
"column_3" "data_type",
CONSTRAINT column_name PRIMARY KEY (column_1, column_2)
... )


It is typical practice to create the constraints at the same time when the table is created with the create statement.Since a FOREIGN_KEY references a known type, you do not need to specify the foreign key's column type.

CREATE TABLE orders (
order_id number primary key
order_date date,
customer_id references customers
)



Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 95 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?