Choose your database:
AnySQL
MySQL
MS SQL Server
PostgreSQL
SQLite
Firebird
Oracle
SQL Anywhere
DB2
MaxDB

Subscribe to our news:
Partners
Testimonials
Alex Torin: "Several months ago I downloaded the trial versions of several Microsoft SQL administration tools that I was able to find using google. I had considerable trouble with most of them crashing... but using your product I was able to isolate and solve the problems I was having. I decided to add it to my toolkit and have recommended it to a few others".
Albert Rognan: "Thank you for this quick reply. I must say I am impressed of the number of functions that is available within this tool".

More

Add your opinion

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

 

open the table in Table Editor and the Default Constraints tab there;
press the Insert key or select the Add Default Constraint... item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar)

or

select the table in the explorer tree and use the Create New Default Constraint popup menu item

or

select the table Default Constraints node or any default constraint within the table in the explorer tree and use the Add New Default Constraint... popup menu item.

 

 

 

Table default constraints are edited within the Default Constraint Properties dialog window. In order to open the dialog you should either

 

open the table in Table Editor and the Default Constraints tab there;
press the Enter key or select the Edit Default Constraint item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar)

or

select the default constraint to edit in the explorer tree and use the Edit Default Constraint popup menu item.

       

You can change the name of the default constraint using the Rename Default Constraint dialog. To open the dialog you should either

 

select the default constraint to rename in the explorer tree;
select the Rename Default Constraint item from the popup menu

or

open the table in Table Editor and the Default Constraints tab there;
select the default constraint to rename;
select the Rename Default Constraint item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar).

 

 

 

To drop the table default constraint:

 

select the default constraint to drop in the explorer tree;
select the Drop Default Constraint item from the popup menu

or

open the table in Table Editor and the Default Constraints tab there;
press the Delete key or select the Drop Default Constraint item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar)

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



Prev Return to chapter overview Next