Using column defaults

Column defaults automatically assign a specified value to a particular column whenever someone enters a new row into a database table. The default value assigned requires no action on the part of the client application, however if the client application does specify a value for the column, the new value overrides the column default value.

Column defaults can quickly and automatically fill columns with information, such as the date or time a row is inserted, or the user ID of the person entering the information. Using column defaults encourages data integrity, but does not enforce it. Client applications can always override defaults.

Supported default values

SQL supports the following default values:

  • A string specified in the CREATE TABLE statement or ALTER TABLE statement
  • A number specified in the CREATE TABLE statement or ALTER TABLE statement
  • AUTOINCREMENT: an automatically incremented number that is one more than the previous highest value in the column
  • Default GLOBAL AUTOINCREMENT, which ensures unique primary keys across multiple databases.
  • Universally Unique Identifiers (UUIDs) generated using the NEWID function.
  • The current date, time, or timestamp
  • The current user ID of the database user
  • A NULL value
  • A constant expression, as long as it does not reference database objects

Creating column defaults
Altering and dropping column defaults
Working with column defaults in Sybase Central
Current date and time defaults
The user ID defaults
The AUTOINCREMENT default
The GLOBAL AUTOINCREMENT default
The NEWID default
The NULL default
String and number defaults
Constant expression defaults