Creates a column object representing an Time datatype.
New-TimeColumn [-Name] <String> [[-Precision] <Int32>] [-Sparse] [-Default <String>] [-Description <String>] [<CommonParameters>]
New-TimeColumn [-Name] <String> [[-Precision] <Int32>] -NotNull [-Default <String>] [-Description <String>] [<CommonParameters>]
Use this function in the Column
script block for Add-Table
:
Add-Table 'WithTime' {
Time 'ColumnName'
}
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Name | String | The column's name. |
true | false | |
Precision | Int32 | The number of decimal digits that will be stored to the right of the decimal point. |
false | false | 0 |
NotNull | SwitchParameter | Don't allow |
true | false | False |
Sparse | SwitchParameter | Store nulls as Sparse. |
false | false | False |
Default | String | A SQL Server expression for the column's default value |
false | false | |
Description | String | A description of the column. |
false | false |
Add-Table 'WithTime' { New-TimeColumn 'CreatedAt' 5 -NotNull }
Demonstrates how to create a required time
column with a given scale when adding a new table.
Add-Table 'WithTime' { Time 'CreatedAt' -Sparse }
Demonstrate show to create a nullable, sparse time
column when adding a new table.
Add-Table 'WithTime' { Time 'CreatedAt' -NotNull -Default 'convert(`time`, getutcdate())' }
Demonstrates how to create a time
column with a default value, in this case the current time. You alwyas use UTC, right?
Add-Table 'WithTime' { Time 'CreatedAt' -NotNull -Description 'The `time` the record was created.' }
Demonstrates how to create a time
column with a description.