MySQL 无法删除表,因为未知表(错误 1051)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36722520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't DROP TABLE because unknown table (ERROR 1051)
提问by kas
I'm trying to drop a table from a schema I inherited. When I SHOW TABLES
I get
我正在尝试从我继承的模式中删除一个表。当SHOW TABLES
我得到
+----------------------------+
| Tables_in_schema_a |
+----------------------------+
| table_1 |
| table_2 |
| table_3 |
| table_4 |
| table_5 |
| table_6 |
+----------------------------+
But when I execute DROP TABLE table_1
I get
但是当我执行DROP TABLE table_1
我得到
ERROR 1051 (42S02): Unknown table 'table_1'
错误 1051 (42S02):未知表“table_1”
I'm using the correct schema. What's going on?
我正在使用正确的架构。这是怎么回事?
P.S. This is MySQL server is 5.1.73.
PS 这是 MySQL 服务器是 5.1.73。
采纳答案by kas
Turns out SHOW TABLES
is actually a bit of a misnomer. That table, table_1
, was unknown because it's actually a view. I ran SELECT table_name, table_type FROM information_schema.tables WHERE table_schema='schema_a'
showed that it's a view. DROP VIEW table_1
deleted it.
事实证明,SHOW TABLES
这实际上有点用词不当。那个表table_1
是未知的,因为它实际上是一个视图。我跑了SELECT table_name, table_type FROM information_schema.tables WHERE table_schema='schema_a'
表明这是一个观点。DROP VIEW table_1
删除了它。
回答by Dani Dissosa
Check whether the table is a VIEW
, if so use the command
检查表是否为 a VIEW
,如果是则使用命令
drop view table_name;