View previous topic :: View next topic
|
Author |
Message |
Alien3
New User
Joined: 03 Nov 2005 Posts: 2
|
|
|
|
Hi,
A column in a table has been defined as Not Null.
I need to make it Not Null with default.
Could somebody please advice how to do it without recreating the table.
Thanks |
|
Back to top |
|
|
ravisan Warnings : 1 New User
Joined: 13 Sep 2005 Posts: 13 Location: chennai
|
|
|
|
I think , we can try using ALTER.......? |
|
Back to top |
|
|
tam
New User
Joined: 02 Nov 2005 Posts: 12 Location: zz
|
|
|
|
I think first you've to drop that column and then add it as not null with default.
ALTER TABLE <table_name>
ADD COLUMN <column_name> <column_type>
NOT NULL WITH DEFAULT |
|
Back to top |
|
|
Alien3
New User
Joined: 03 Nov 2005 Posts: 2
|
|
|
|
Hi Tam,
Thanks for the suggestion but the table contains data.
If i drop the column won't i lose the data? |
|
Back to top |
|
|
tam
New User
Joined: 02 Nov 2005 Posts: 12 Location: zz
|
|
|
|
Hi Alien3,
Yeah you'll lose data but I'm not sure if you can update the column type without dropping the column. |
|
Back to top |
|
|
|