MS SQL Maestro online Help
Prev | Return to chapter overview | Next |
Default constraints
Default Constraints can be used to provide values for a new column in the existing rows of data. SQL Server defaults provide data to columns and user-defined data types when no other data is available on an INSERT statement execution. Constraints allow you to define the way Microsoft® SQL Server automatically enforces the integrity of a database. Constraints define rules regarding the values allowed in columns and are the standard mechanism for enforcing integrity.
Table default constraints are created within the Default Constraint Properties dialog window. In order to open the dialog you should either
or
or
|
Table default constraints are edited within the Default Constraint Properties dialog window. In order to open the dialog you should either
or
You can change the name of the default constraint using the Rename Default Constraint dialog. To open the dialog you should either
or
|
To drop the table default constraint:
or
and confirm dropping in the dialog window.
|
allows you to add a new default constraint or edit an existing one. It is available from Table Editor, or from the corresponding nodes of the explorer tree.
The Default Constraint Properties window allows you to set the constraint name, enter some optional text describing it, select a field to define the default constraint on, and also to specify the default value.
Note: the name of the object must be unique among all the object names in its container. Moreover, all the objects that are source of data need unique names among themselves. You can use any identifier that is allowed by Microsoft SQL server.
Note: default constraints cannot be added to columns that have a timestamp data type, an Identity property, an existing default constraint, or a bound default. If the column has an existing default constraint, the default must be dropped before the new default can be added.
See also: Defaults