ITeye博客

mysql 多表删除陷阱(跨库schema+别名的语法错误问题)

floydd · 2012-03-09 15:55 · db · 数据库 · Markdown

* 登陆用户为demo

* 连接字符串串中指定默认库是demo

* 另一个数据库(schema)是demo2,demo用户拥有demo2的所有访问权限

 

delete f,s from tableF f left join tableS s on f.fid=s.fid

- result=ok

 

delete f,s from demo.tableF f left join demo.tableS s on f.fid=s.fid

- result=ok

 

delete f,s from demo2.tableF f left join demo2.tableS s on f.fid=s.fid

- result=error,bad sql grammar :(

 

delete demo2.tableF,demo2.tableS from demo2.tableF left join demo2.tableS on demo2.tableF.fid=demo2.tableS.fid

- result=ok

可见,mysql在跨库使用schema来执行多表删除时不能给表取别名。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。