SQL query to get the syntax of an existing table
You can use SHOW CREATE TABLE &lt;table_name&gt;; to get CREATE TABLE statement.
  Eg. SHOW CREATE TABLE acl_user_role; This will show you the table name and CREATE TABLE statement, something like:


CREATE TABLE `acl_user_role` (
  `UserId` INT(10) UNSIGNED NOT NULL,
  `RoleId` SMALLINT(5) UNSIGNED NOT NULL,
  PRIMARY KEY (`UserId`,`RoleId`),
  KEY `FK_UserRole_Role` (`RoleId`),
  CONSTRAINT `FK_UserRole_Role` FOREIGN KEY (`RoleId`) REFERENCES `acl_role` (`RoleId`),
  CONSTRAINT `FK_UserRole_User` FOREIGN KEY (`UserId`) REFERENCES `user` (`UserId`)
) ENGINE=INNODB DEFAULT CHARSET=utf8



  If you want to know about Keys for a particular table, use something like SHOW KEYS FROM acl_user_role;


And if you want to get all keys and constraints referencing to other table (like foreign key references), use:

SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE`
WHERE TABLE_NAME = '&lt;your_table_name&gt;' AND TABLE_SCHEMA = '&lt;your_database_name&gt;';

-- Example
SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE`
WHERE TABLE_NAME = 'acl_user_role' AND TABLE_SCHEMA = 'db_shop';


Hope this may help you...