Solved

mysql table exists and doesn't

Posted on 2009-07-15
3
2,223 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
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:
ushastry earned 500 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now