Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7834431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:08:58+00:00 2026-06-02T13:08:58+00:00

I want to drop a table with drop table EMPLOYEE; but I get the

  • 0

I want to drop a table with drop table EMPLOYEE;

but I get the error: #1217 - Cannot delete or update a parent row: a foreign key constraint fails

I looked around on the internet to show the hidden constraints and found:

CREATE TABLE `EMPLOYEE` (
`Ssn` int(9) NOT NULL,
`Dno` int(11) NOT NULL,
UNIQUE KEY`Ssn_8` (`Ssn`),
UNIQUE KEY`Dno_13` (`Dno`),
CONSTRAINT `EMPLOYEE_ibfk_1` FOREIGN KEY(`Dno`) REFERENCES `DEPARTMENT` (`Dnumber`),
CONSTRAINT `EMPLOYEE_ibfk_2` FOREIGN KEY(`Dno`) REFERENCES `DEPARTMENT` (`Dnumber`),
CONSTRAINT `EMPLOYEE_ibfk_3` FOREIGN KEY(`Dno`) REFERENCES `EMPLOYEE` (`Dno`),
CONSTRAINT `EMPLOYEE_ibfk_4` FOREIGN KEY(`Dno`) REFERENCES `EMPLOYEE` (`Dno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1




   CREATE TABLE `DEPARTMENT` (
`Dnumber` int(11) NOT NULL,
`Mgr_ssn` int(9) NOT NULL,
UNIQUE KEY`Mgr_ssn` (`Mgr_ssn`),
UNIQUE KEY`Dnumber` (`Dnumber`),
CONSTRAINT `DEPARTMENT_ibfk_1` FOREIGN KEY(`Mgr_ssn`) REFERENCES `EMPLOYEE` (`Ssn`),
CONSTRAINT `DEPARTMENT_ibfk_2` FOREIGN KEY(`Mgr_ssn`) REFERENCES `EMPLOYEE` (`Ssn`),
CONSTRAINT `DEPARTMENT_ibfk_3` FOREIGN KEY(`Mgr_ssn`) REFERENCES `DEPARTMENT` (`Mgr_ssn`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

After finding this I tried dropping the contraints first with:
alter table EMPLOYEE drop contraint 'EMPLOYEE_ibfk_1';

but I keep getting:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''EMPLOYEE_ibfk_1'' at line 1

I have worked at dropping this table for several hours now and searched many topics on the internet. People ended up dropping the db, but I am unauthorized to drop db or create a db.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T13:09:02+00:00Added an answer on June 2, 2026 at 1:09 pm

    First remove the FOREIGN KEY constraints from DEPARTMENT to EMPLOYEE (note the weird syntax, you should use DROP FOREIGN KEY but with the constraint(!) identifier):

    ALTER TABLE DEPARTMENT
      DROP  FOREIGN KEY  DEPARTMENT_ibfk_1 ,
      DROP  FOREIGN KEY  DEPARTMENT_ibfk_2 ;
    

    Then drop the EMPLOYEE table:

    DROP TABLE EMPLOYEE ; 
    

    The problem with your code was that you used DROP CONSTRAINT – which is correct, AFAIK it is the standard SQL syntax for ALTER TABLE.

    MySQL however, “prefers” DROP FOREIGN KEY. In other words, it doesn’t comply with standards in this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to drop a table but it is referenced by one or more
I want to drop a now supposedly redundant file in SQL Server (2005), but
I want to generate drop shadows. But it is difficult to generate cross platform
I want to use cursor to delete record from table. How can I do
Where do temporary tables get stored in a database? I want to drop a
I want to drop a # temp table when running then macro, is it
I'm trying to drop a few tables with the DROP TABLE command but for
Every time I want to drop a constraint from a column I get an
I have a table and I want to drop or set the default value
I want to drop a table in my SQLite Database file named database.db. After

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.