Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle 如何创建唯一约束_Oracle_Constraints - Fatal编程技术网

Oracle 如何创建唯一约束

Oracle 如何创建唯一约束,oracle,constraints,Oracle,Constraints,我有一种编程情况,在这种情况下,我必须检查表中某一列的唯一性 假设我的表是employee表,并且我添加了一列代码。现在我必须阻止插入MGR和MGR 这意味着我不能有两行不区分大小写的值 如何添加检查约束?如果使用Oracle,可以在列的小写字母上添加唯一索引 create unique index <index_name> on <tablename>(lower(<column_name>)) 在(lower())上创建唯一索引 仅为完整说明:唯一约束和

我有一种编程情况,在这种情况下,我必须检查表中某一列的唯一性

假设我的表是employee表,并且我添加了一列代码。现在我必须阻止插入
MGR
MGR

这意味着我不能有两行不区分大小写的值


如何添加检查约束?

如果使用Oracle,可以在列的小写字母上添加唯一索引

create unique index <index_name> on <tablename>(lower(<column_name>))
在(lower())上创建唯一索引

仅为完整说明:唯一约束和唯一索引之间存在细微差别。唯一约束可以是外键约束的目标,唯一索引不能。唯一索引可以基于表达式(如本答案中所述),唯一约束不能基于表达式定义。