Mysql Error Number 1217
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of rails mysql2::error: cannot delete or update a parent row: a foreign key constraint fails this site About Us Learn more about Stack Overflow the company Business Learn
Mysql Delete Foreign Key Constraint
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question cannot update a parent row: a foreign key constraint fails x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Bogus
Error 1451 Mysql
foreign key constraint fail up vote 95 down vote favorite 39 I get this error message: ERROR 1217 (23000) at line 40: Cannot delete or update a parent row: a foreign key constraint fails ... when I try to drop a table: DROP TABLE IF EXISTS `area`; ... defined like this: CREATE TABLE `area` ( `area_id` char(3) COLLATE utf8_spanish_ci NOT NULL, `nombre_area` varchar(30) foreign_key_checks COLLATE utf8_spanish_ci NOT NULL, `descripcion_area` varchar(100) COLLATE utf8_spanish_ci NOT NULL, PRIMARY KEY (`area_id`), UNIQUE KEY `nombre_area_UNIQUE` (`nombre_area`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci; The funny thing is that I already dropped all other tables in the schema that have foreign keys against area. Actually, the database is empty except for the area table. How can it possibly have child rows if there isn't any other object in the database? As far as I know, InnoDB doesn't allow foreign keys on other schemas, does it? (I can even run a RENAME TABLE area TO something_else command :-?) mysql innodb share|improve this question edited Jan 18 at 15:02 asked Jul 26 '10 at 12:06 Álvaro González 81.1k20133201 Is it possible that the table is a part of a Referential-Integrity relationship in another schema? –Raj More Jul 26 '10 at 12:21 I have some other copies of the app so it's always possible. However, the syntax I use is basically CONSTRAINT fk_servicio_area1 FOREIGN KEY (area_id) REFERENCES area (area_id), i.e., no schema name on the table reference :-? –Álvaro González Jul 26 '10 at 12:38 add a comment| 9 Answers
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of
Mysql On Delete Cascade
this site About Us Learn more about Stack Overflow the company Business Learn
Remove Foreign Key Constraint
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question mysql foreign key constraint x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up http://stackoverflow.com/questions/3334619/bogus-foreign-key-constraint-fail Error code 1217 in MySQL code [duplicate] up vote 0 down vote favorite This question already has an answer here: Bogus foreign key constraint fail 9 answers I'm getting the error: Error 1217 in my MySQL code. My MySQL code is DROP TABLE IF EXISTS Formed; DROP TABLE IF EXISTS Album; DROP TABLE IF EXISTS Band; DROP TABLE IF EXISTS Customers; DROP TABLE IF http://stackoverflow.com/questions/36629400/error-code-1217-in-mysql-code EXISTS Track; CREATE TABLE Formed( FormedID int AUTO_INCREMENT, YearFormed int, CountryFormed varchar(50), CityFormed varchar(50), BandMembers varchar(400), PRIMARY KEY(FormedID)) ENGINE=InnoDB; CREATE TABLE Track ( TrackID int AUTO_INCREMENT, AlbumID int AUTO_INCREMENT, Songs varchar (100), TrackNumber varchar (20), Title varchar (30), TrackDuration varchar (4), PRIMARY KEY (TrackID)) ENGINE=InnoDB; CREATE TABLE Album( AlbumID int AUTO_INCREMENT, TrackID int AUTO_INCREMENT, BandID int AUTO_INCREMENT, KEY(TrackID), KEY(BandID), Price varchar(5), PublicationDate varchar(11), Title varchar(30), Genre varchar (36), PRIMARY KEY(AlbumID)) ENGINE=InnoDB; CREATE TABLE Band( BandID int AUTO_INCREMENT, AlbumID int AUTO_INCREMENT, KEY(AlbumID), RecordLabel varchar(50), PRIMARY KEY(BandID)) ENGINE=InnoDB; CREATE TABLE Customers ( CustomerID int AUTO_INCREMENT, CName varchar (20), CPhone int (11), CEmail varchar (50), CPPaid varchar (50), CPDate date, PRIMARY KEY (CustomerID)) ENGINE=InnoDB; ALTER TABLE Track ADD FOREIGN KEY (AlbumID) REFERENCES Album(AlbumID)ON DELETE SET NULL ON UPDATE CASCADE; ALTER TABLE Album ADD FOREIGN KEY (TrackID) REFERENCES Track(TrackID)ON DELETE SET NULL ON UPDATE CASCADE; ALTER TABLE Album ADD FOREIGN KEY (BandID) REFERENCES Band(BandID)ON DELETE SET NULL ON UPDATE CASCADE; ALTER TABLE Band ADD FOREIGN KEY (AlbumID) REFERENCES Album(AlbumID)ON DELETE SET NULL ON UPDATE CASCADE; And I'm getting the error DROP TABLE IF EXISTS Album Error Code: 1217. Cannot delete or upda
Connectors More MySQL.com Downloads Developer Zone Section Menu: Documentation Home MySQL 5.7 Reference Manual Preface and Legal Notices General Information Installing and Upgrading MySQL http://dev.mysql.com/doc/en/error-messages-server.html Using MySQL as a Document Store Tutorial MySQL Programs MySQL Server Administration Security Backup and Recovery Optimization Language Structure Globalization Data Types Functions and Operators SQL Statement Syntax The InnoDB Storage Engine Alternative Storage Engines High Availability and Scalability Replication MySQL Cluster NDB 7.5 Partitioning Stored Programs and Views INFORMATION_SCHEMA Tables MySQL Performance Schema MySQL foreign key sys Schema Connectors and APIs Extending MySQL MySQL Enterprise Edition MySQL Workbench MySQL 5.7 Frequently Asked Questions Errors, Error Codes, and Common Problems Sources of Error Information Types of Error Values Server Error Codes and Messages Client Error Codes and Messages Problems and Common Errors How to Determine What Is Causing a Problem Common Errors foreign key constraint When Using MySQL Programs Access denied Can't connect to [local] MySQL server Lost connection to MySQL server Client does not support authentication protocol Password Fails When Entered Interactively Host 'host_name' is blocked Too many connections Out of memory MySQL server has gone away Packet Too Large Communication Errors and Aborted Connections The table is full Can't create/write to file Commands out of sync Ignoring user Table 'tbl_name' doesn't exist Can't initialize character set File Not Found and Similar Errors Table-Corruption Issues Administration-Related Issues Problems with File Permissions How to Reset the Root Password What to Do If MySQL Keeps Crashing How MySQL Handles a Full Disk Where MySQL Stores Temporary Files How to Protect or Change the MySQL Unix Socket File Time Zone Problems Query-Related Issues Case Sensitivity in String Searches Problems Using DATE Columns Problems with NULL Values Problems with Column Aliases Rollback Failure for Nontransactional Tables Deleting Rows from Related Tables Solving Problems with No Matching Rows Problems with Floating-Point Values