SQL Server/T-SQL/Constraints/Constraints Basics — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 13:46, 26 мая 2010
Enable a column to optionally not require a value by designating it as a nullable column
1> -- Nullability
2>
3> -- Enable a column to optionally not require a value by designating it as a
4> -- nullable column.
5>
6> CREATE TABLE MyTable
7> ( Category nVarChar(50) NOT NULL
8> , MyDescription nVarChar(50)
9> )
10> INSERT MyTable (Category) VALUES ("Category1")
11>
12> SELECT * FROM MyTable
13> GO
(1 rows affected)
Category MyDescription
-------------------------------------------------- -------------------------------
Category1 NULL
(1 rows affected)
1>
2> drop table MyTable
3> GO
1>
NOT NULL column and NULL column
1> CREATE TABLE MyTable
2> ( Category nVarChar(50) NOT NULL
3> , MyDescription nVarChar(50) NULL
4> )
5>
6>
7> INSERT MyTable (Category) VALUES ("Category1")
8>
9> SELECT * FROM MyTable
10> GO
(1 rows affected)
Category MyDescription
-------------------------------------------------- -----------------
Category1 NULL
(1 rows affected)
1>
2> drop table MyTable
3> GO
1>