È possibile creare una chiave primaria o un indice univoco all'interno di un'istruzione CREATE TABLE di SQL Server. È possibile creare un indice non univoco all'interno di un'istruzione CREATE TABLE?
CREATE TABLE MyTable(
a int NOT NULL
,b smallint NOT NULL
,c smallint NOT NULL
,d smallint NOT NULL
,e smallint NOT NULL
-- This creates a primary key
,CONSTRAINT PK_MyTable PRIMARY KEY CLUSTERED (a)
-- This creates a unique nonclustered index on columns b and c
,CONSTRAINT IX_MyTable1 UNIQUE (b, c)
-- Is it possible to create a non-unique index on columns d and e here?
-- Note: these variations would not work if attempted:
-- ,CONSTRAINT IX_MyTable2 INDEX (d, e)
-- ,CONSTRAINT IX_MyTable3 NONCLUSTERED INDEX (d, e)
);
GO
-- The proposed non-unique index should behave identically to
-- an index created after the CREATE TABLE statement. Example:
CREATE NONCLUSTERED INDEX IX_MyTable4 ON MY_TABLE (d, e);
GO
Anche in questo caso, l'obiettivo è creare l'indice non univoco all'interno dell'istruzione CREATE TABLE, non dopo di essa.
Per quello che vale, non ho trovato utile la [voce della documentazione in linea di SQL Server relativa a CREATE TABLE] .
Inoltre, [Questa domanda] è quasi identica, ma la risposta accettata non si applica.