简体   繁体   English

将查询从oracle转换为mysql

[英]Conversion of query from oracle to mysql

How to convert the below query from oracle to mysql. 如何将下面的查询从oracle转换为mysql。

ALTER table test ADD CONSTRAINT TEST_FK FOREIGN KEY (id) REFERENCES another_table(id) ON DELETE CASCADE ENABLE NOVALIDATE; ALTER table test ADD CONSTRAINT TEST_FK FOREIGN KEY(id)在删除级联启用NOVALIDATE时引用another_table(id);

When i convert this I got the following error in mysql 当我将其转换时,我在mysql中收到以下错误

Error Code: 1064. You have an error in your SQL syntax; 错误代码:1064。 check the manual that corresponds to your MySQL server version for the right syntax to use near 'ENABLE NOVALIDATE' Can any body please help me on this. 请检查与您的MySQL服务器版本相对应的手册,以在“ ENABLE NOVALIDATE”附近使用正确的语法 。请问有没有机构可以帮助我。

Thanks SKP 谢谢SKP

This is standard syntax of adding a foreign key using alter query Official 这是使用alter query添加外键的标准语法Official

ALTER TABLE tbl_name
ADD [CONSTRAINT [symbol]] 
    FOREIGN KEY [index_name] (index_col_name, ...)
    REFERENCES tbl_name (index_col_name,...)
    [ON DELETE reference_option]
    [ON UPDATE reference_option]

in your query delete ENABLE NOVALIDATE . 在查询中删除ENABLE NOVALIDATE Try this 尝试这个

ALTER table test 
  ADD CONSTRAINT TEST_FK 
      FOREIGN KEY (id) REFERENCES another_table(id) 
      ON DELETE CASCADE;

Example http://dev.mysql.com/doc/refman/5.7/en/create-table-foreign-keys.html 范例 http://dev.mysql.com/doc/refman/5.7/en/create-table-foreign-keys.html

ALTER TABLE products
  ADD FOREIGN KEY fk_vendor(vdr_id) REFERENCES vendors(vdr_id)
      ON DELETE NO ACTION
      ON UPDATE CASCADE;

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

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