我是SQL新手并在安装了Oracle 11g的命令提示符下运行它
CREATE table Transaction(
Transaction_Id number PRIMARY KEY,
Account_No number FOREIGN KEY REFERENCES Account_creation(Account_No),
Transaction_Date date,
Amount number,
Transaction_type varchar2(5) CHECK( Transaction_type=’C’ OR Transaction_type=’D’),
Current_Balance number,
Branch_code varchar2(10) );
我在第4行得到错误907,说错了右括号 我做错了什么?
答案 0 :(得分:1)
如果这一行真的正确:
Transaction_type varchar2(5) CHECK( Transaction_type=’C’ OR Transaction_type=’D’),
然后你在行中有错误的单引号。试试这个:
Transaction_type varchar2(5) CHECK( Transaction_type = 'C' OR Transaction_type = 'D'),
或者,更好的是:
Transaction_type varchar2(5) CHECK( Transaction_type in ('C', 'D')),
答案 1 :(得分:0)
CREATE table Transaction(
Transaction_Id number PRIMARY KEY,
Account_No number,
Transaction_Date date,
Amount number,
Transaction_type varchar2(5) CHECK( Transaction_type=’C’ OR Transaction_type=’D’),
Current_Balance number,
Branch_code varchar2(10),
FOREIGN KEY (Account_No) REFERENCES Account_creation(Account_No)
);