Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

mysql table exists and doesn't

Posted on 2009-07-15
3
Medium Priority
?
2,378 Views
Last Modified: 2012-05-07
I am trying to restore from a dump:

DROP TABLE IF EXISTS `patients`;
CREATE TABLE `patients` (
  `patientID` int(11) NOT NULL auto_increment,
  `QS1CODE` varchar(24) character set utf8 collate utf8_bin default NULL,
  `DoctorCode` int(11) default NULL,
....
  PRIMARY KEY  (`patientID`)
) ENGINE=InnoDB AUTO_INCREMENT=184163 DEFAULT CHARSET=utf8;



And I get:

ERROR 1051 (42S02): Unknown table 'patients'
ERROR 1050 (42S01): Table 'patients' already exists
ERROR 1146 (42S02): Table 'rperry_wha.patients' doesn't exist
ERROR 1146 (42S02): Table 'rperry_wha.patients' doesn't exist
ERROR 1146 (42S02): Table 'rperry_wha.patients' doesn't exist
ERROR 1146 (42S02): Table 'rperry_wha.patients' doesn't exist
ERROR 1146 (42S02): Table 'rperry_wha.patients' doesn't exist
ERROR 1146 (42S02): Table 'rperry_wha.patients' doesn't exist
0
Comment
Question by:rperry_wha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Expert Comment

by:racek
ID: 24861666
add name of the schema

DROP TABLE IF EXISTS perry_wha.patients;
0
 

Author Comment

by:rperry_wha
ID: 24861703
I've tried that:

mysql> use rperry_wha;
Database changed
mysql> drop table rperry_wha.patients;
ERROR 1051 (42S02): Unknown table 'patients'
mysql> FLUSH TABLES;
Query OK, 0 rows affected (0.00 sec)

mysql> drop table rperry_wha.patients;
ERROR 1051 (42S02): Unknown table 'patients'
mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.00 sec)

mysql> UNLOCK TABLES ;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH TABLES;
Query OK, 0 rows affected (0.00 sec)

mysql> drop table rperry_wha.patients;
ERROR 1223 (HY000): Can't execute the query because you have a conflicting read lock
0
 
LVL 26

Accepted Solution

by:
Umesh earned 1500 total points
ID: 24862077
It seems you have copied InnoDB tables from one server to another..and you ended up having only .frm files and no reference to that table in InnoDB data files/data dictionary..  those tables are orphan tables and can't be simply dropped using SQL DROP command... you need to manually delete the files from the file system ( .frm files )

You just locate the patients.frm file in the MySQL's datadir/rperry_wha/patients.frm  once you delete this file manually you can execute/import the SQL file as you were trying earlier.

For more details better you take a look at the MySQL error log.... which instructs you in similar way
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question