Documentation Home
MySQL 5.6 リファレンスマニュアル
Download this Manual
PDF (US Ltr) - 26.8Mb
PDF (A4) - 26.9Mb
HTML Download (TGZ) - 7.1Mb
HTML Download (Zip) - 7.2Mb SHOW CREATE TABLE 構文


指定されたテーブルを作成する CREATE TABLE ステートメントを表示します。このステートメントを使用するには、そのテーブルに対する何らかの権限が必要です。また、このステートメントはビューでも機能します。

*************************** 1. row ***************************
       Table: t
Create Table: CREATE TABLE t (
  id INT(11) default NULL auto_increment,
  s char(60) default NULL,

SHOW CREATE TABLE は、sql_quote_show_create オプションの値に従って、テーブル名とカラム名を引用符で囲みます。セクション5.1.4「サーバーシステム変数」を参照してください。

User Comments
  Posted by Eject Disc on October 21, 2005
This is useful when you want to change a column name or definition with:

ALTER TABLE foobar CHANGE old_field_name new_field_name old_field_definition

You want to maintain the same column type, so having the original column definition at your fingers tips is handy.

This features seems to be from 4.0 release series onwards.

  Posted by Lou Picciano on April 19, 2006
This 'ENGINE=' syntax is important; don't forget to look through your older code for similar 'TYPE=' designations. There are some well-know applications which are choking on 'TYPE=HEAP', for example, reporting a Syntax Error.

If people are not familiar with switching ENGINE types, this one can bite you!
  Posted by Matt Piskorz on May 12, 2006
You can also use create table if not exists [database].[table]

Replace [database] with the database of where the table should be created.

Replace [table] with the table name you want created.

example: (This will create a table called user in the test database)

create table if not exists test.user
UserID varchar(50)
, Password varchar(50)
) Engine=InnoDB;

  Posted by Stephen Dewey on August 14, 2006
This might go without saying for most folks, but just so you know, this statement does not necessarily return the same statement that was actually used to create the table in the first place. It returns a statement which if run at the current time will recreate the given table with its current structure (not including the data). So if you create a table, then alter it, then run the SHOW CREATE TABLE command, it will return a statement that acts as if the change represented by your ALTER command were incorporated into your initial CREATE TABLE command.
  Posted by Rodolfo Campos on March 14, 2011
At the end, if you just want to retrieve column: names, types and comments as in a data dictionary you can forget this command... I've found it too complex to parse.

You can check an script (in spanish) that I've created at:
Sign Up Login You must be logged in to post a comment.