简体   繁体   English

使用表名中的特殊字符删除MySQL(3.23.58)中的表

[英]Dropping a table in MySQL (3.23.58) with a special character in the tablename

Yes this is an old db (we are in the process of migrating). 是的,这是一个旧的数据库(我们正在迁移过程中)。 Somehow, phpMyAdmin let a user create a table with a ' in it. 不知何故,phpMyAdmin让用户创建一个带有'的表。

name: type_save' name:type_save'

But, I cannot seem to drop that table now. 但是,我现在似乎无法放弃那张桌子。 I have tried this from the commandline: 我从命令行试过这个:

mysql> drop table "type_save\'";
ERROR 1064: You have an error in your SQL syntax near '"type_save\'"' at line 1                                                                          

mysql> drop table "type_save'";
ERROR 1064: You have an error in your SQL syntax near '"type_save'"' at line 1    


mysql> drop table `type_save'`;
'>                                                                                      

How do you properly escape this? 你怎么逃脱这个?

Thanks... 谢谢...

According to Does MySQL allows to create database with dot? 根据MySQL是否允许用点创建数据库? you use backticks to quote the name, as in 你使用反引号引用名称,如

drop table `type_save'`

Try that and see if it helps. 试试看,看看是否有帮助。

Try this: 尝试这个:

mysql> drop table `type_save'`;

Note: "mysql>" is only the command prompt. 注意:“mysql>”只是命令提示符。

Character is ` ( reverse apostrophe or left single quote). 字符是`( 反向撇号或左单引号)。

It's MySQL 3.x, so it's very likely MyISAM (or even ISAM). 它是MySQL 3.x,所以它很可能是MyISAM(甚至是ISAM)。 Since the normal way to drop the table isn't working (since you say it crashes the server), and if it's MyISAM/ISAM, just delete the relevant .MYI , .MYD , and .frm files straight from the filesystem, or move them elsewhere if you need to preserve them for some reason. 由于删除表的正常方法不起作用(因为你说它崩溃服务器),如果它是MyISAM / ISAM,只需直接从文件系统中删除相关的.MYI.MYD.frm文件,或者移动如果你出于某种原因需要保存它们,别的地方。 Then do a flush tables. 然后做一个冲洗表。 You don't even need to shut down the server (at least on Unix, on Windows the file may be in use and Windows may not let you delete it. Flush tables may help). 你甚至不需要关闭服务器(至少在Unix上,在Windows上文件可能正在使用,Windows可能不允许你删除它。刷新表可能有帮助)。

Do not do this if its InnoDB, only ISAM or MyISAM. 如果它的InnoDB只有ISAM或MyISAM,请不要这样做。

If its InnoDB, I'm afraid you may have a dump/reload in your future. 如果它的InnoDB,我担心你将来可能会有转储/重装。

And have backups, of course. 当然还有备份。 Always have backups. 始终有备份。

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

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