ORA-00907:创建表时缺少右括号

时间:2014-03-18 14:41:26

标签: oracle11g runtime-error

我正在尝试创建3个表,但我收到此错误:

CREATE TABLE dj_abonent 
( 
dj_klientID INT NOT NULL PRIMARY KEY, 
emer_klienti varchar2(10), 
mbiemer_klienti VARCHAR2(10),
sasia_cel INT
);

CREATE TABLE dj_phones
(
 phone_number varchar2(12),
 activated number(1) default 0,
 activation_date date default null,
 CONSTRAINT dj_phone_number_check
CHECK (substr(phone_number,1,5) in( '35566','35567','35568','35569') ),
 CONSTRAINT dj_activated_check
  CHECK (activated in(1,0) ) 
dj_KlientID int FOREIGN KEY REFERENCES dj_Abonenti(dj_KlientID)
);

CREATE TABLE dj_telef
(
start_time date,
end_time date,
abonent_1 varchar2(10),
abonent_2 varchar2(10)
);

Error at Command Line : 26 Column : 17
Error report -
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 -  "missing right parenthesis"
*Cause:    
*Action:

1 个答案:

答案 0 :(得分:0)

行号来自您的SQL Developer脚本窗口,这并不完全有用,因为它似乎与问题不符。可能还有其他一些事情,但是在检查约束之后你错过了一个逗号(就像a previous question)。但是你应该把约束放在命令的末尾:

CREATE TABLE dj_phones
(
 phone_number varchar2(12),
 activated number(1) default 0,
 activation_date date default null,
 dj_KlientID int FOREIGN KEY REFERENCES dj_Abonenti(dj_KlientID)
 CONSTRAINT dj_phone_number_check
  CHECK (substr(phone_number,1,5) in( '35566','35567','35568','35569') ),
 CONSTRAINT dj_activated_check
  CHECK (activated in(1,0) ) 
);

如果您使用run statement命令(control-enter)一次运行一个语句,或者通过突出显示文本一个命令并使用运行脚本(F5),您可能会发现调试这些问题更容易。 / p>