List:General Discussion« Previous MessageNext Message »
From:Markus Fischer Date:September 24 2004 3:11pm
Subject:Re: Unable top drop table, error 1051
View as plain text  
Hi,

Egor Egorov wrote:
> Can you create a test case? I.e. a .sql file which is supposed to drop the 
> table well but instead fails? 

Nevermind my last post, I found the workaround to disable foregin_key_checks during
import; interesting.

Here is a small example:

set foreign_key_checks=0;

CREATE TABLE `produkt_kategorie` (
  `pk_id` int(10) unsigned NOT NULL auto_increment,
  `pk_pt_id_typ` int(10) unsigned NOT NULL default '0',
  `pk_kategorie` varchar(255) default NULL,
  `pk_sortid` int(10) unsigned default NULL,
  PRIMARY KEY  (`pk_id`),
  KEY `produk_kategorie_FKIndex1` (`pk_pt_id_typ`),
  CONSTRAINT `produkt_kategorie_ibfk_1` FOREIGN KEY (`pk_pt_id_typ`) REFERENCES
`produktkategorie_typ` (`pt_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) TYPE=InnoDB;


CREATE TABLE `produktkategorie_typ` (
  `pt_id` int(10) unsigned NOT NULL auto_increment,
  `pt_name` varchar(255) default NULL,
  `pt_sortid` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`pt_id`)
) TYPE=InnoDB;

set foreign_key_checks=1;

When I now try to drop the table produktkategorie_typ I get the error:

#1051 - Unknown table 'produktkategorie_typ' 

I think it's because of the constraint, but then the error message is missldeading.

So basically I would need to disable the foreign_key_checks every time I drop a table
which has constraints?

I see the bigger picture now I guess, just didn't while trying to achive this with
phpmyadmin.

thanks,
- Markus
Thread
Unable top drop table, error 1051Markus Fischer22 Sep
  • Re: Unable top drop table, error 1051Egor Egorov24 Sep
    • Re: Unable top drop table, error 1051Markus Fischer24 Sep
    • Re: Unable top drop table, error 1051Markus Fischer24 Sep
      • Re: Unable top drop table, error 1051Egor Egorov27 Sep
      • Re: Unable top drop table, error 1051Egor Egorov28 Sep
        • Re: Unable top drop table, error 1051Markus Fischer29 Sep