select constraint name

Light Poster
21Jul2007,16:46   #1
kalaid's Avatar
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.
Go4Expert Member
10Jan2008,13:36   #2
Windhan's Avatar
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 `fk_test_mast_id`  (`mast_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Hope it is clear now !!!!