Sunday, February 24, 2013

query for table definition on mysql

in the console, issue:


show create table my_tables_name;

and it will show the table definition...

for example:

mysql> show create table client_users;
+--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table        | Create Table                                                                                                                                                                                   |
+--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| client_users | CREATE TABLE `client_users` (
  `id` varchar(36) NOT NULL,
  `client_id` varchar(36) NOT NULL,
  `user_id` varchar(36) NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |


(for cakePHP guys: I wanted not to use a HABTM)


No comments:

Post a Comment