Is there a work around for using the ALTER TABLE command to add a column that is "NOT NULL"? for instance, can we add a NULL column, then change it to be NOT NULL in a two-step process? Thanks
You can use the alter table by rename method.
for example
if you have a table named mytable
you would script it out and create a table named mytable2 with the new field added to it.
The insert all the data from mytable into mytable2
Rename mytable to mytable_old
and rename mytable2 to mytable
Or
you could just create a default for the new field you are adding.
alter table mytable add column mycolumn int default 0
- Paul
- Database performance looks fine, it must be the Network!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.