Creates a Default constraint to an existing column
Add-DefaultConstraint [-TableName] <String> [-SchemaName <String>] [-ColumnName] <String> [-Name <String>] [-Expression] <String> [-WithValues] [<CommonParameters>]
The DEFAULT constraint is used to insert a default value into a column. The default value will be added to all new records, if no other value is specified.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
TableName | String | The name of the target table. |
true | false | |
SchemaName | String | The schema name of the target table. Defaults to |
false | false | dbo |
ColumnName | String | The column on which to add the default constraint |
true | false | |
Name | String | The name for the |
false | false | |
Expression | String | The default expression |
true | false | |
WithValues | SwitchParameter | WithValues |
false | false | False |
Add-DefaultConstraint -TableName Cars -ColumnName Year -Expression '2015'
Adds an Default constraint on column 'Year' in the table 'Cars'