gracylayla (7) [Avatar] Offline
#1
DDL Commands are used to define structure of the table

1. CREATE
It is used to create database objects like tables, views, synonyms, indexes.
Creating Table:
Syntax-
Create table table_name(columname1 datatype(size), columname2 datatype(size),....);


2. ALTER
It is used to change existing table structure.
Alter:: a) add
b) modify
c)drop
a) Add:
It is used to add columns into existing table
Syntax:
Alter table table_name add(columnname1 datatype(size), columname2 datatype(size),....);


b) Modify:
It is used to change column Datatype or datatype size only.
Syntax:
Alter table table_name modify(columnname1 datatype(size), columnname2 datatype(size),....);


c) Drop:
It is used to drop columns from the table.
Method1:
If we want to drop single column at a time without using parentheses then we are using following syntax.
Syntax:
alter table   table_namedrop column   col_name1;  -- drop ONE column


Method2:
If we want to drop single or multiple columns at a time with using paranthesis then we are using following syntax.
Syntax:
alter table table_name drop(column_name_list);


Note:
In all databases we can’t drop all columns in the table.

3. DROP
It is used to remove database objects from database.
Syntax:
Drop object object_name; 
       (or)
Drop table table_name;  
       (or)
Drop view view_name;


4. RENAME
It is used to renaming a table.
Syntax:
Rename old table_name to new table_name;


Renaming a column:
Syntax:
Alter table table_name rename column old column_name to new column_name;


5. TRUNCATE
Oracle 7.0 introduced truncate table command it is used to delete all rows permanently from the table.
Syntax:
truncate table table_name;


Know More About SQL Click Here!