SQL Server/T-SQL Tutorial/Constraints/NewID

Материал из SQL эксперт
Перейти к: навигация, поиск

UniqueIdentifier are either explicitly provided or they are generated by the NEWID() system function.

   <source lang="sql">

7> CREATE TABLE MyTable (MyID UniqueIdentifier NOT NULL DEFAULT NewID() 8> , MyDescription nVarChar(50) NOT NULL) 9> 10> INSERT MyTable (MyID, MyDescription) VALUES (DEFAULT, "SQL Server generated GUID") 11> 12> select * from MyTable; 13> drop table MyTable; 14> GO (1 rows affected) MyID MyDescription


--------------------------------------------------

230A2164-ACD7-4E86-82CA-C92C28A4030C SQL Server generated GUID (1 rows affected) 1></source>