#1064-您的SQL语法有误;检查与您的MySQL服务器版本相对应的手册 [英] #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

查看:560
本文介绍了#1064-您的SQL语法有误;检查与您的MySQL服务器版本相对应的手册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Sybase Power Designer从物理数据模型创建数据库(Sybase创建SQL文件).当我使用phpMyAdmin导入SQL文件时,出现以下错误:

I am using Sybase Power Designer to create a database from a physical data model (Sybase creates an SQL file) . When i import the SQL file with phpMyAdmin I have the following error:

#1064-您的SQL语法有错误;请检查与您的MySQL服务器版本相对应的手册,以获取在'如果存在(在sys.sysforeignkey中选择1,其中role ='FK_ARTWORK_CREATES_ARTIST'在第7行)附近使用正确语法的正确语法.

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if exists(select 1 from sys.sysforeignkey where role='FK_ARTWORK_CREATES_ARTIST'' at line 7 .

有什么想法吗?该错误可能是由于物理模型上的错误而出现的,还是存在另一个问题?

Any ideas? Could this error appear due to errors on the physical model or there is another problem?

这是代码:

if exists(select 1 from sys.sysforeignkey where role='FK_ARTWORK_HAS_BUY') then
    alter table artwork
       delete foreign key FK_ARTWORK_HAS_BUY
end if;

推荐答案

您收到的错误来自MySQL.不管用于生成SQL的工具是什么,数据库似乎都是MySQL(或者,如果系统感到困惑并认为它们是MySQL,那么您的系统就会出现严重错误).

The error you are getting is from MySQL. Regardless of the tool used to generate SQL, the database seems to be MySQL (or something is terribly wrong with your systems if they are confused and think they are MySQL).

MySQL if语句(在此处记录)必须在存储的程序中.这意味着该代码仅在存储过程,用户定义的函数或触发器内编译.它本身不能正常工作".

The MySQL if statement (documented here) has to be inside a stored program. That means that this code only compiles inside a stored procedure, user defined function, or trigger. It doesn't "just work" on its own.

此外,MySQL没有sys表.它使用information_schema表.我最强烈的建议是使用适合您实际数据库的工具.如果使用的是生成Sybase的工具,请使用Sybase作为目标数据库.如果使用的是MySQL,请使用工具生成MySQL代码.或者,更好的是,学习如何自己编写命令.

In addition, MySQL doesn't have sys tables. It uses information_schema tables. My strongest suggestion is to use tools appropriate for your actual database. If you are using a tool to generate Sybase, then use Sybase as the destination database. If you are using MySQL, then use a tool to generate MySQL code. Or, better yet, learn how to write the commands yourself.

最后,如果您打算使用Sybase,请连接到正确的数据库,然后应解决您的问题.

Finally, if you intend to use Sybase, then connect to the correct database and your problem should be fixed.

这篇关于#1064-您的SQL语法有误;检查与您的MySQL服务器版本相对应的手册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆