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

  • Home
  • SEARCH
  • 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 8617515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:52:44+00:00 2026-06-12T05:52:44+00:00

I created one script to display the foreign keys in the particular table. SELECT

  • 0

I created one script to display the foreign keys in the particular table.

SELECT  i.CONSTRAINT_NAME FROM information_schema.TABLE_CONSTRAINTS i
LEFT JOIN information_schema.KEY_COLUMN_USAGE k ON
i.CONSTRAINT_NAME = k.CONSTRAINT_NAME WHERE i.CONSTRAINT_TYPE = 'FOREIGN KEY'
AND i.TABLE_NAME = 'sample';

When I execute this command in my host, it displays the list of foreign key constraints found in all the databases with table name "sample".

But i need particular database, sample table foreign keys.

  • 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-12T05:52:45+00:00Added an answer on June 12, 2026 at 5:52 am

    just add at the end

    AND i.table_schema = '<the name of your database which is a schema>'
    

    EDIT :

    Change the left join to

    LEFT JOIN information_schema.KEY_COLUMN_USAGE
       ON i.CONSTRAINT_NAME = k.CONSTRAINT_NAME AND 
          i.TABLE_SCHEMA = k.TABLE_SCHEMA
    

    because you could find constraint with same name in different schemas.

    what’s a schema and a database in mysql

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

Sidebar

Related Questions

I create one table by using jquery : <div class=productlist style=float:left; id=productlist> <script type=text/javascript
I have created one ruby script that I want to run with some flags
I have created one multiplication of complex function using prototype in java-script function ComplexNumber(real,imaginary)
I created one app for database which contains a student table and 3 fields
I created a script which get from my database the states and price of
I have created (with help from other scripts found online) a slideshow script that
I'm trying to pass a dynamically created id from a form to JavaScript. <script
I've created a form with one drop down menu to choose from as well
I have two scripts that are called in one program, the first script creates
I created one linear layout and I have added two relative layout. I wish

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.