CREATE TABLE the_user( Name VARCHAR(40) not null,
Address VARCHAR(255) not null,
Delivery_address VARCHAR(255),
Email VARCHAR(25) not null,
Phone INTEGER not null,
Status INTEGER not null,
Password VARCHAR(25) not null,
DOB DATE not null,
PRIMARY KEY (Email),
FOREIGN KEY (Status) REFERENCES User_Status (Status_Id),
CONSTRAINT check_Password CHECK (Password > 4)
);
INSERT INTO the_user VALUES (
'Pergrin Took',
'12 Bag end, hobbiton, The Shire, Eriador',
'The address, Dublin',
'ptook@lotr.com',
'8679046',
'001',
'treebeard',
TO_DATE('2013/11/04 14:11:34', 'yyyy/mm/dd hh24:mi:ss')
);
我在Oracle中有上述数据库,但是当我尝试运行insert命令时,我收到一个ORA-1722错误,无效数字。 user_status表中有一个条目,对应于插入中的1。
我已经坚持了好几天。
答案 0 :(得分:1)
引号不是问题 - 只要它们有效,它就会被隐式转换为数字。
检查你的约束:
CONSTRAINT check_Password CHECK (Password > 4)
在这里,您尝试比较字符串和数字 - >在这种比较中,Oracle总是试图将两者都作为数字 - >密码失败,您看到错误。
尝试使用而不是密码,例如'55',你会看到插入行。
也许你想这样做?
CONSTRAINT check_Password CHECK (length(Password) > 4)