Does anyone know why Vertica enforces the NOT NULL constraint, but not the UNIQUE constraint?
Code: Select all
dbadmin=> create table beth (col1 int not null, col2 varchar unique);
CREATE TABLE
dbadmin=> insert into beth (col1) values (null);
ERROR 2502: Cannot set a NOT NULL column (col1) to a NULL value in INSERT/UPDATE statement
dbadmin=> insert into beth (col1, col2) values (1, 'Beth');
OUTPUT
--------
1
(1 row)
dbadmin=> insert into beth (col1, col2) values (2, 'Beth');
OUTPUT
--------
1
(1 row)
dbadmin=> select * from beth;
col1 | col2
------+------
1 | Beth
2 | Beth
(2 rows)
Code: Select all
dbadmin=> select analyze_constraints('beth');
Schema Name | Table Name | Column Names | Constraint Name | Constraint Type | Column Values
-------------+------------+--------------+-----------------+-----------------+---------------
public | beth | col2 | C_UNIQUE | UNIQUE | ('Beth')
(1 row)