Thursday 20 March 2014

alter table add column in SQL

Suppose your table has already created and in mean time you want to change the table Colum, it means you want to add the colum in table

alter table  cust_table add   cust_name varchar2(50);

If you want it should be not null Colum than you need to specify it as Not Null
alter table  cust_table add   cust_name varchar2(50) Not Null;


If you want to specify this should have some default value than you need to put default values like
alter table  cust_table add   cust_name varchar2(50) DEFAULT ‘xxxxx’ Not Null;


Colum which is already exist and you want to modify it than.
alter table    Cust_Table    modify   cust_name  NOT NULL;

No comments:

Post a Comment