Altering columns with user-defined datatypes  Dropping a column with user-defined datatypes

Chapter 8: Creating Databases and Tables

Adding a column with user-defined datatypes

Use the same syntax to add a column with a user-defined datatype as with a system-defined datatype. For example, to add a column to the authors table of pubs2 using the usertype datatype:

alter table titles
add newcolumn usertype not null

The NULL or NOT NULL default you specify takes precedence over the default specified by the user-defined datatype. That is, if you add a column and specify NOT NULL as the default, the new column has a default of NOT NULL even if the user-defined datatype specifies NULL. If you do not specify NULL or NOT NULL, the default specified by the user-defined datatype is used.

Reviewers   Author comment:  Added clause to para below:”unless the user-defined datatype has a default bound to it,” in response to CR 264661, 11/30/01 rjoly.

You must supply a default clause when you add columns that are not null, unless the user-defined datatype already has a default bound to it.

If the user-defined datatype specifies IDENTITY column properties (precision and scale), the column is added as an IDENTITY column.





Copyright © 2005. Sybase Inc. All rights reserved. Dropping a column with user-defined datatypes

View this book as PDF