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 9044455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:59:38+00:00 2026-06-16T10:59:38+00:00

I want to add a second foreign key constraint between data and containers .

  • 0

I want to add a second foreign key constraint between data and containers. When I delete a container, the data linked to this container has to be deleted too.

The tables:

mysql> DESCRIBE data;
+------------------------+--------------+------+-----+---------------------+----------------+
| Field                  | Type         | Null | Key | Default             | Extra          |
+------------------------+--------------+------+-----+---------------------+----------------
| imei                   | varchar(15)  | NO   | MUL | NULL                |                

mysql> DESCRIBE containers;
+--------------------+-------------+------+-----+---------------------+----------------+
| Field              | Type        | Null | Key | Default             | Extra          |
+--------------------+-------------+------+-----+---------------------+----------------+

| imei               | varchar(15) | NO   | MUL | NULL                |                |

I create a foreign key with this statement:

 mysql> ALTER TABLE `data` ADD FOREIGN KEY (`imei`) REFERENCES `containers`(`imei`) ON DELETE CASCADE;
    Query OK, 15168 rows affected (0.12 sec)
    Records: 15168  Duplicates: 0  Warnings: 0

But the foreign key hasn’t been created:

 mysql> use INFORMATION_SCHEMA;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    mysql> select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE where REFERENCED_TABLE_NAME = 'containers';
    +----------------+-------------+-----------------------+-----------------------+------------------------+
    | TABLE_NAME     | COLUMN_NAME | CONSTRAINT_NAME       | REFERENCED_TABLE_NAME | REFERENCED_COLUMN_NAME |
    +----------------+-------------+-----------------------+-----------------------+------------------------+
    | container_logs | imei        | container_logs_ibfk_1 | containers            | imei                   |
    +----------------+-------------+-----------------------+-----------------------+------------------------+
    1 row in set (0.16 sec)

What am I doing wrong?

  • 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-16T10:59:40+00:00Added an answer on June 16, 2026 at 10:59 am

    Not all storage engines support foreign keys; storage engines that does not support certain SQL features however do not generate error, but just ignore the statements (actually the SQL parser is higher layer in the MySQL architecture, which uses lower-level APIs to communicate with the storage engines).

    So if you are using MyISAM, you cannot create a foreign key, but no error will be returned

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

Sidebar

Related Questions

I want to add a second Address field into this custom function (ie. Apt.
I have this LINQ query and want to add a second orderby. var clients
I want add new Feed item on entity persist and update. I write this
I want add my custom sidebar next right column all page. Please check this
In visual studio i want to add a second code behind file to a
i have 2 NSMutableArray with same type. i want to add second nsmutablearray to
I want to add the class 'second-col' to all second TD's in each row,
I want to add data in two tables form one controller file when I
i got 2 dynamic texture ,and want add second texture color to first texture
I know how to create bundle using console. Now I want to add second

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.