SQL Server/T-SQL Tutorial/Constraints/Create Default

Материал из SQL эксперт
Версия от 13:25, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Creation of Default Values

   <source lang="sql">

The syntax of this statement is

     CREATE DEFAULT default_name
       AS expression

sp_bindefault is used to bind the defined default value to specific columns. 11> 12> CREATE DEFAULT zip_default AS 94710 13> GO 1> 2> CREATE TYPE zip 3> FROM CHAR(5) NOT NULL 4> GO 1> 2> 3> sp_bindefault "zip_default", "zip" 4> 5> --sp_unbindefault removes the connection between the default and the data type of the corresponding column. 6> 7> sp_unbindefault "zip_default", "zip" 8> 9> drop DEFAULT zip_default; 10> 11> drop type zip; 12> GO</source>


Defaults

   <source lang="sql">

5> 6> CREATE DEFAULT df_Region AS "PNW" 7> GO 1> 2> drop DEFAULT df_Region; 3> GO</source>