不区分大小写检查约束

Ste*_*enC 0 sql oracle novaclient

创建了下表:

CREATE TABLE VEHICLES

(vehicleVIN VARCHAR(30) PRIMARY KEY,

vehicleType VARCHAR(30) NOT NULL CHECK (vehicleType IN ('compact', 'midsize', 'fullsize', 'suv', 'truck')),

vehicleWhereFrom VARCHAR(30) NOT NULL CHECK (vehicleWhereFrom IN ('maryland','virginia','washington, d.c.'));
Run Code Online (Sandbox Code Playgroud)

运行insert命令时,带有大写字母的条目(例如:Compact,COMPACT,Maryland,VIRGINIA等)违反了检查约束(错误ORA-02290).如何使检查约束不区分大小写?只要单词拼写正确,所需的结果就是接受插入的数据,无论使用何种情况.通过NOVA使用Oracle数据库.谢谢!

Vam*_*ala 5

使用lower检查列的小写版本.

CHECK vehicleType VARCHAR(30) NOT NULL CHECK (lower(vehicleType) IN ('compact', 'midsize', 'fullsize', 'suv', 'truck')),
CHECK vehicleWhereFrom VARCHAR(30) NOT NULL CHECK (lower(vehicleWhereFrom) IN ('maryland','virginia','washington, d.c.'));
Run Code Online (Sandbox Code Playgroud)