select constraint name

kalaid's Avatar
Light Poster
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.
Windhan's Avatar, Join Date: Jan 2008
Go4Expert Member
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 !!!!