MySQL将注释添加到外键 [英] MySQL Adding COMMENT to a Foreign Key
问题描述
我正在将一个旧的数据库SyBase转换为MySQL,并且我有这个DDL查询:
I'm translating an old database SyBase to MySQL and I have this DDL Query:
ALTER TABLE "DBA"."tab_prodotto"
ADD FOREIGN KEY "fkey_idlinea" ("tpr_idlin")
REFERENCES "DBA"."linea" ("lin_id")
go
COMMENT ON FOREIGN KEY "DBA"."tab_prodotto"."fkey_idlinea" IS
'Riferimento linea'
go
查询的Alter部分工作良好,但是我在COMMENT上遇到了麻烦.我已经知道可以更改添加COMMENT的列,但是外键也可以吗?如果是,怎么办?我在文档上没有发现任何特别之处.预先谢谢你.
The Alter part of query works well, but I have troubles on COMMENT. I already know that I can alter a column for adding a COMMENT, but is that possible for foreign keys too? If yes, how? I haven't find nothing special on documentation. Thank you in advance.
推荐答案
The MySQL reference manual shows the allowed syntax for the FOREIGN KEY
command to be:
[CONSTRAINT [symbol]] FOREIGN KEY
[index_name] (index_col_name, ...)
REFERENCES tbl_name (index_col_name,...)
[ON DELETE reference_option]
[ON UPDATE reference_option]
reference_option:
RESTRICT | CASCADE | SET NULL | NO ACTION
没有允许的 COMMENT
部分.看来这是不允许的.
There is no allowable COMMENT
section. It looks like this is not allowed.
我上面引用的手册来自5.6版.我检查了5.1和5.5版本,语法是一样的.
The manual I referenced above is from version 5.6. I checked versions 5.1 and 5.5 and the syntax is the same.
这篇关于MySQL将注释添加到外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!