CREATE TABLE statement is used to create table objects in database.You can create tables with different column data types.It is possible to add CONSTRAINTS like primary key ,foreign key etc while creating the table or can be added after the table creation.
Let us see the examples one by one.
Create table with data types
SQL> create table MYTABLE(name VARCHAR2(50),id NUMBER,salary NUMBER(8,2)); Table created
Now let us INSERT few records into MYTABLE.
SQL> insert into MYTABLE values ('CCC',1,2548.21); SQL> insert into MYTABLE values ('ADS',2,3548.21); SQL> insert into MYTABLE values ('GDS',2,1548.21); SQL> select * from MYTABLE ORDER BY SALARY; NAME ID SALARY GDS 2 1548.21 CCC 1 2548.21 ADS 2 3548.21
Related Articles,Oracle/PLSQL: Foreign Keys with ON DELETE CASCADE optionORA-02449: unique/primary keys in table referenced by foreign
ORA-02292: integrity constraint violated – child record found
ORA-02291: integrity constraint violated – parent key not Found
Oracle/PLSQL: Foreign Keys | Oracle Referential Integrity
Oracle/PLSQL: Composite Primary Key
Oracle/PLSQL: Primary Key and Composite Primary Key
Technorati Tags:
CREATE TABLE statement, CREATE TABLE, create table oracle
Pingback: Oracle 'ALTER TABLE' command to ADD columns syntax | SQL and PLSQL
Pingback: CREATE INDEX as part of CREATE TABLE statement. | SQL and PLSQL
Pingback: Oracle Tables: Create table with foreign key constraint | SQL and PLSQL
Pingback: ‘CREATE TABLE’ : create table with composite primary key | SQL and PLSQL
Pingback: Oracle Tables: CREATE TABLE statement: create a table with primary key. | SQL and PLSQL
Pingback: Oracle/PLSQL:Create Table as Select statement | SQL and PLSQL
Pingback: Oracle/PLSQL: Create table with foreign key constraint | SQL and PLSQL
Pingback: CREATE TABLE statement: create a table with composite primary key | SQL and PLSQL
Pingback: Oracle PL/SQL:CREATE TABLE statement: create a table with primary key. | SQL and PLSQL