Add Not Null Column in a Table

How we can add a NotNull Column in a table by using alter command (without using default command)?

Questions by mamtasahu

Showing Answers 1 - 2 of 2 Answers

UncaAlby

  • Oct 20th, 2008
 

First add the column as NULL. Then populate the column with non-null data. Then modify the column to NOT NULL. You may need to set dboption "select into" to True.

Tejas More

  • Jul 7th, 2011
 

You can add a NOT NULL column to a table. This means that a constant expression, and not a null value, is placed in the column when the column is added. This also ensures that, for all existing rows, the new column is populated with the specified constant expression when the table is created.

Adaptive Server issues an error message if a user fails to enter a value for a NOT NULL column.

The following adds the column owner to the stores table with a default value of “unknown:”

alter table stores add owner_lname varchar(20) default "unknown" not null

  Was this answer useful?  Yes

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