4 ms·
>CREATE UNIQUE INDEX (filtered) Ha...that's a bit of a hack! I've had to do a similar trick for a unique constraint on columns where we didn't care if the val
by Mouse47 9y ago
>CREATE UNIQUE INDEX (filtered)
Ha...that's a bit of a hack! I've had to do a similar trick for a unique constraint on columns where we didn't care if the value was null. SQL Server (for some reason) considers null a value in this case; in other words, there could only be one null value in the table for purposes of a unique constraint.
E.g:
create unique index on (col) where col is not null
- snuxoll 9y agoStuff like this always makes me glad PostgreSQL takes adherence to the SQL standard seriously, NULLS are supposed to be considered non-equal for unique indexes - probably some stupid design from the Sybase days that MS decided was easier to keep for compatibility than change, though.