yogish
yogish

Reputation: 85

Adding not null to a TEXT type column in Sybase ASE

I am not able to add a TEXT type column to a table in sybase ASE with not null constraint. I am able to add TEXT column, but "not null" constraint not able to add.

Or how to modify TEXT column to add "not null" constraint. When I try to modify a TEXT column, am getting error "You cannot modify column colName to TEXT/IMAGE/UNITEXT type". Please suggest how to add or modify a text type column with not null constraint.

Upvotes: 0

Views: 666

Answers (1)

Rich Campbell
Rich Campbell

Reputation: 576

You can create a brand new table with a non-nullable text column but you can't alter a table and add a non-nullable text column because the value within that text column needs to be set to comply with your 'not null' request.

This for example works fine and creates the table with the appropriate setting:

create table foo (col1 int not null, col2 text not null)

You cannot also modify a table's text/image column attribute once created so you would have to create it as a new table then copy your old table data over and populate your text data at the same time (given that the column is non-nullable)

Upvotes: 0

Related Questions