我正在尝试运行我的代码,但它一直给我这个错误。我是SQL的新手,还没有习惯它,所以我一直在尝试对其进行修复,但似乎无法使其正常工作。我已将两个表都放入下面的描述代码中。
Create table Account
(
Account_Number Number(7,0)
Constraint PK_Account_Account_Number Primary Key
Constraint NN_Account_Account_Number Not Null,
Account_Balance Number(13,2)
Constraint NN_Account_Account_Balance Not Null
);
Create table Investor
(
Investor_Number Number(7,0)
Constraint PK_Investor_Investor_Number Not Null,
First_Name Varchar2(25)
Constraint NN_Investor_First_Name Not Null,
Last_Name Varchar2(30)
Constraint NN_Investor_Last_Name Not Null,
Street_Address Varchar2(35)
Constraint NL_Investor_Street_Address Null,
City Varchar2(25)
Constraint NL_Investor_City Null,
Province Char(2)
Constraint CK_Investor_Province Check (Province in ('__'))
Constraint NL_Investor_Province Null,
Postal_Code Varchar2(7)
Constraint CK_Investor_Postal_Code Check (REGEXP_like(string,'[A-Z]-[0-9]-[A-Z]-[0-9]-[A-Z]-[0-9]'))
Constraint NL_Investor_Posta_Code Null,
Area_Code Number(3,0)
Default '780'
Constraint NN_Investor_Area_Code Not Null,
Phone_Number Number(7,0)
Constraint NN_Investor_Phone_Number Not Null,
Account_Number Number(7,0) Not Null,
Constraint FK__Investor_Account_Number --Name of Constraint
Foreign Key (Account_Number) -- Foreign Key Column name
References Account(Account_Number)-- name of table and column trying to reference,
);
答案 0 :(得分:1)
Postal_Code
中的检查约束是指string
而不是实际的列名;应该是:
Postal_Code Varchar2(7)
Constraint CK_Investor_Postal_Code Check
(REGEXP_like(Postal_Code,'[A-Z]-[0-9]-[A-Z]-[0-9]-[A-Z]-[0-9]'))
Constraint NL_Investor_Postal_Code Null,
您得到的错误是因为解析器将string
解释为标识符,并假设它是另一列的名称,即使不是。显然没有别的东西了,所以这也不是完全不合理的。