LoginSignup
2

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...> ファイル名

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
2