1
2

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 5 years have passed since last update.

MySQL 自分用メモ

Last updated at Posted at 2015-10-05

SQL文

CSV出力

SELECT
  'カラム名1','カラム名2','カラム名3',... 
UNION
SELECT
  `カラム1`,
  `カラム2`,
  `カラム3`,
  ...
FROM `テーブル` 
WHERE ...
INTO OUTFILE "/path/to/filename.csv" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"';

全テーブルのレコード数

select table_name, table_rows from information_schema.TABLES
where table_schema = 'DB名';

SQLコマンド

DB全体のテーブル構造ダンプ

$ mysqldump -u ユーザ名 -p -d データベース名 > ファイル名

複数テーブルのデータのみダンプ

$ mysqldump -u ユーザ名 -p -t データベース名 テーブル1 テーブル2...> ファイル名
1
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?