How to create a constraint for a tablecolumn which is already created

Questions by subbaraovangalli   answers by subbaraovangalli

Showing Answers 1 - 9 of 9 Answers

priya_sri

  • Apr 6th, 2007
 

Hi,You can create constraints using Alter commandAlter table add constraint column

  Was this answer useful?  Yes

To add  primary key or unique key constraint

Alter table tablename add constraint constraintname  primary key / unique (column name)

To add check constraint
Alter table tablename add constraint constraintname  check (codition)


To add not null constraint
Alter table tablename modify (columnname not null)

To add  foreign key constraint
Alter table tablename add constraint constraintname foreign key(columnname) references referencedtablename(referenced columnname)

Note- We can not add primary key or not null constraint on  a column that contains null values.
We can not add unique key or primary key constraint on a column that constains duplicate vlaues

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions