ORA-02253: constraint specification not allowed here

半城伤御伤魂 提交于 2019-12-08 05:11:15

问题


create table log_table(
log_id varchar2(1000) primary key,
voter_ID varchar2(1000),
date_logged date
CONSTRAINT abc FOREIGN KEY (voter_ID) REFERENCES voters(voter_ID)
)

The table works when i create it without date element. But when i add the date element to it says:

ORA-02253: constraint specification not allowed here


回答1:


The table works when i create it without date element

create table log_table(
log_id varchar2(1000) primary key,
voter_ID varchar2(1000),   -- comma
CONSTRAINT abc FOREIGN KEY (voter_ID) REFERENCES voters(voter_ID)
)

You have to add , before constraint:

create table log_table(
log_id varchar2(1000) primary key,
voter_ID varchar2(1000),
date_logged date, -- here
CONSTRAINT abc FOREIGN KEY (voter_ID) REFERENCES voters(voter_ID)
)

I would also reconsider datatype of log_id/voter_id as (NUMBER/INTEGER).




回答2:


Try this:

create table log_table(
log_id varchar2(1000) primary key,
voter_ID varchar2(1000) CONSTRAINT abc REFERENCES voters(voter_ID)
)


来源:https://stackoverflow.com/questions/45751511/ora-02253-constraint-specification-not-allowed-here

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!