Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sybase/ALTER TABLE: how to turn an existing column from non-nullable to nullable?

Hopefully the title has made it quite clear.

I would like to see an example of a alter table statement that can change an existing non-nullable column in a Sybase table to nullable.

like image 793
Anthony Kong Avatar asked Jul 06 '11 08:07

Anthony Kong


People also ask

How do you change a column to nullable in a table?

ALTER TABLE table_name ALTER COLUMN column_name DATA_TYPE [(COLUMN_SIZE)] NULL; In this syntax: First, specify the name of the table from which you want to change the column. Second, specify the column name with size which you want to change to allow NULL and then write NULL statement .

How do I change the default value in a column in Sybase?

The following statement changes the default value of a column named OrderDate from its current setting to CURRENT DATE: ALTER TABLE SalesOrders ALTER OrderDate DEFAULT CURRENT DATE; You can remove column defaults by modifying them to be NULL.


1 Answers

Modifying the NULL default value of a column:

If you are changing only the NULL default value of a column, you do not need to specify a column's datatype

(Switching the example from the above link):

alter table authors
modify address null
like image 70
Damien_The_Unbeliever Avatar answered Sep 21 '22 11:09

Damien_The_Unbeliever