Search notes:

Oracle: UNIQUE constraint

Unique constraints on columns that are nullable

create table tq84_uq (
   x   number   not null,
   y   varchar2(10) null,
   val number,
   unique(x,y)
);
 
insert into tq84_uq values (1,'one', 1);
insert into tq84_uq values (1, null, 0);
insert into tq84_uq values (2, null, 2);
 
-- ORA-00001: unique constraint .... violated
insert into tq84_uq values (2, null, 3);

Adding unique constraints

alter table T add                            unique(col[, col_2…]);
alter table T add constraint constraint_name unique(col[, col_2…]);

See also

Referential integrity from a foreign key to a unique constraint

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759421525, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/objects/tables/constraints/unique/index(55): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78