英文:
What do "near "CASCADE"" and "near "CONSTRAINTS" error mean in MySQL?
问题
对于SQL术语的错误使用,我深感抱歉,我仍然是个新手。因此,我从一个关系模型生成了一个DDL脚本,将其转换为MySQL,并尝试在phpMyAdmin中运行它,但无论我做什么都遇到了失败,因为出现了以下错误:
无法识别的关键字(在位置203附近)
意外的假设(在位置211附近)
如果有人有建议,我将非常乐意接受。
我将提供出现错误的实际代码行(这也是脚本的第一行):
DROP TABLE ad CASCADE CONSTRAINTS;
这个脚本是用于一个数据库的。我尝试在实体模型中进行“反向工程”,并生成一个不同的脚本,但是同样的错误仍然出现。
英文:
I apologise for the incorrect use of sql terms, I'm still a novice. So, I produced a ddl script from a relational model, converted it to MySQL and tried to "run" (the app Im' running it at is called phpMyAdmin) it but whatever I did was met with failure as these error kept occuring:
Unrecognized keyword. (near "CASCADE" at position 203)
Unexpected presumption. (near "CONSTRAINTS" at position 211)
If anybody has a word of advice I'd gladly accept it.
I'll provide the actual line of code that the error occures (which is the first line of the script too):
DROP TABLE ad CASCADE CONSTRAINTS;
The script is for a database. I tried to "reverse enngineer" it in the entity model and priduce a different script but the same error kept occuring.
答案1
得分: 0
从MySQL文档我们可以看到,您的命令语法是非法的。
实际上,在MySQL中,您无法像您想要的那样级联删除:
RESTRICT
和 CASCADE
允许从其他数据库系统进行迁移。在MariaDB中,它们不起作用。
希望对您有所帮助。
英文:
From the MySQL docs we can see that your command syntax is illegal.
<br>
<br>In fact in MySQL you can't delete on cascade like you want to do it :
> RESTRICT
and CASCADE
are allowed to make porting from other database systems easier. In MariaDB, they do nothing.
Hope it help you.
答案2
得分: 0
错误意味着关键词“Cascade”和“Constraint”未被识别,因为它们用于在删除父表的所有行之后删除子表的所有行。
尝试使用以下代码:
DROP TABLE ad;
它将运行并且不会给您任何错误。
英文:
@Brad Troll Error means keywords " Cascade" and "Constraint" are unrecognized as they are used to delete all rows from the child table once all tables from the parent table are deleted.
Try using the code :
DROP TABLE ad;
It will run and will not give you any error.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论