1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

テーブルを作成したときのコマンドを確認する SHOW CREATE TABLE

Posted at

用途

既にあるテーブルを作成した際のコマンドを確認したい時に使う。
SQL文を真似したいときなど、このコマンドを使うことで、以前にテーブルを作成した際のSQL文が観れるので参考になる。

使用方法

SHOW CREATE TABLE テーブル名;

見たいテーブル名を指定するだけ。

結果

| テーブル名 | CREATE TABLE テーブル名 (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
hoge_id int(10) unsigned NOT NULL,
hoge text,
created datetime DEFAULT NULL,
updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE (hoge_id, hoge)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ここにはコメントが表示されます。'

これはあくまでも例です。
このSQLの意味などはこちらにまとめてあります。
https://qiita.com/marukome/items/1e359bdc2a91f52bf875

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?