Reputation: 968
I'm trying to drop a table from a schema I inherited. When I SHOW TABLES
I get
+----------------------------+
| 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
ERROR 1051 (42S02): Unknown table 'table_1'
I'm using the correct schema. What's going on?
P.S. This is MySQL server is 5.1.73.
Upvotes: 10
Views: 43509
Reputation: 9
try the following command:
DROP TABLE database_name.table_name;
or
DROP TABLE `table_name`;
Upvotes: 0
Reputation: 109
Check whether the table is a VIEW
, if so use the command
drop view table_name;
Upvotes: 10
Reputation: 968
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.
Upvotes: 12