1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

select constraint name

Discussion in 'MySQL' started by kalaid, Jul 21, 2007.

  1. kalaid

    kalaid New Member

    Joined:
    Jul 21, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Hi
    I have set constraint for my table with user constraint name. I want to view all the constraints created by me , is there is any option for this.
     
  2. Windhan

    Windhan New Member

    Joined:
    Jan 9, 2008
    Messages:
    11
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Chennai
    Y not...

    Try this.

    Code:
    mysql> CREATE TABLE test_mast(id INTEGER NOT NULL PRIMARY KEY,v_name VARCHAR(100));
    Query OK, 0 rows affected (0.01 sec)
    
    Code:
    mysql> CREATE TABLE test_child(id INTEGER NOT NULL PRIMARY KEY,mast_id INTEGER NOT NULL,det                     VARCHAR(100));
    Query OK, 0 rows affected (0.02 sec)
    
    Code:
    mysql> ALTER TABLE test_child ADD CONSTRAINT fk_test_mast_id FOREIGN KEY(mast_id) REFERENCES                     test_mast(id);
    Query OK, 0 rows affected (0.02 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    Code:
    mysql> SHOW CREATE TABLE test_child;
    +------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table      | Create Table                                                                                                                                                                                                            |
    +------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | test_child | CREATE TABLE `test_child` (
      `id` int(11) NOT NULL,
      `mast_id` int(11) NOT NULL,
      `det` varchar(100) default NULL,
      PRIMARY KEY  (`id`),
      KEY [B]`[COLOR=DarkRed]fk_test_mast_id[/COLOR]` [/B] (`mast_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
    +------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    Hope it is clear now !!!!
     
    shabbir likes this.

Share This Page