>Facendo il constraint Unique, viene creato automaticamente un
>nonclustered index unique.. vero??
Si. I BOL dicono: "The Database Engine automatically creates a UNIQUE index to enforce the uniqueness requirement of the UNIQUE constraint. Therefore, if an attempt to insert a duplicate row is made, the Database Engine returns an error message that states the UNIQUE constraint has been violated and does not add the row to the table. Unless a clustered index is explicitly specified, a unique, nonclustered index is created by default to enforce the UNIQUE constraint".
Se vuoi he venga creato un indice clustered puoi sempre specificarlo nel comando CREATE|ALTER TABLE in base alla sintassi:
<column_constraint> ::=
[ CONSTRAINT constraint_name ]
{ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ]
[
WITH FILLFACTOR = fillfactor
| WITH ( < index_option > [ , ...n ] )
]
>Giusto per sapere se quello che ho sempre fatto è del tutto sbagliato.
Definire un indice per garantire l'univocità è "sbagliato" dal punto di vista logico.
Ciao!
--
Lorenzo Benaglia
Microsoft MVP - SQL Server
http://blogs.dotnethell.it/lorenzo/
http://italy.mvps.org