问题
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