简体   繁体   English

在SQL中更改脚本 - ORA 01735

[英]Alter Scripts in SQL - ORA 01735

I've tried searching this topic, and my searches led me to this format, which is still throwing an error. 我试过搜索这个主题,我的搜索引导我采用这种格式,这仍然是一个错误。 When I execute my script, I basically get a load of ORA-01735 errors for all my later statements. 当我执行我的脚本时,我的所有后续语句基本上都会出现ORA-01735错误。 I had it done out differently, but googling led me to this format, which still doesn't work. 我完成了不同的工作,但谷歌搜索引导我这种格式,但仍然无效。 Any tips? 有小费吗?

CREATE TABLE table7
(
column1 int NOT NULL,
column2 int NOT NULL,
column3 int NOT NULL
)
/

ALTER TABLE table7

ADD(    pk1 PRIMARY KEY(column1),
    fk1 FOREIGN KEY(column2) REFERENCES Table1(column2),
    fk2 FOREIGN KEY(column3) REFERENCES Service(column3)
)
/

ADD should surround each column definition. ADD应围绕每个列定义。 You don't wrap a single ADD around 3 new columns. 您不会围绕3个新列包装单个ADD

See: http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_3001.htm#i2183462 请参阅: http//docs.oracle.com/cd/B28359_01/server.111/b28286/statements_3001.htm#i2183462

For Primary Key and Foreign Key constraints you need the CONSTRAINT keyword. 对于Primary Key和Foreign Key约束,您需要CONSTRAINT关键字。 See: http://docs.oracle.com/javadb/10.3.3.0/ref/rrefsqlj81859.html Section on "adding constraints". 请参阅: http//docs.oracle.com/javadb/10.3.3.0/ref/rrefsqlj81859.html “添加约束”部分。

EDIT: This was the only thing that worked on the fiddle I tried: 编辑:这是我试过的唯一的小提琴:

ALTER TABLE table7
ADD (
      CONSTRAINT pk1 PRIMARY KEY (column1),
      CONSTRAINT fk1 Foreign Key (column2) REFERENCES Table1 (column2),
      CONSTRAINT fk2 Foreign Key (column3) REFERENCES Service (column3)
    )

Here's the fiddle: http://sqlfiddle.com/#!4/9d2a3 这是小提琴: http ://sqlfiddle.com/#!4/ 9d2a3

Check this out: 看一下这个:

ALTER TABLE table7
ADD pk1 PRIMARY KEY(column1),
ADD fk1 FOREIGN KEY(column2) REFERENCES Table1(column2),
ADD fk2 FOREIGN KEY(column3) REFERENCES Service(column3)

See syntax and examples: 请参阅语法和示例:

http://docs.oracle.com/cd/E17952_01/refman-5.1-en/alter-table.html http://docs.oracle.com/cd/E17952_01/refman-5.1-en/alter-table.html

http://docs.oracle.com/cd/E17952_01/refman-5.1-en/alter-table-examples.html http://docs.oracle.com/cd/E17952_01/refman-5.1-en/alter-table-examples.html

ALTER TABLE table7 ADD ( CONSTRAINT pk1 PRIMARY KEY (column1), CONSTRAINT fk1 Foreign Key (column2) REFERENCES Table1 (column2), CONSTRAINT fk2 Foreign Key (column3) REFERENCES Service (column3) ) ALTER TABLE table7 ADD(CONSTRAINT pk1 PRIMARY KEY(column1),CONSTRAINT fk1 Foreign Key(column2)REFERENCES Table1(column2),CONSTRAINT fk2 Foreign Key(column3)REFERENCES Service(column3))

it works for me .Thanks 它对我有用。谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM