mysql常用コマンド収集要約ノート
1148 ワード
1.すべてのテーブルのデータ容量を問い合わせる
クエリー・データベース内のテーブルのデータ容量
2.クエリmysqlでロックされたスレッド
3.mysqldump sqlスクリプトのエクスポート時に1つ以上のテーブルを除外
4.mysqldump where条件に基づいて、あるテーブルの条件に合致するデータをエクスポートする
5.mysqldump指定されたテーブルの構造とデータのエクスポート
SELECT
table_schema AS ' ',
table_name AS ' ',
table_rows AS ' ',
TRUNCATE ( data_length / 1024 / 1024, 2 ) AS ' (MB)',
TRUNCATE ( index_length / 1024 / 1024, 2 ) AS ' (MB)'
FROM
information_schema.TABLES
ORDER BY
data_length DESC,
index_length DESC;
クエリー・データベース内のテーブルのデータ容量
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from information_schema.TABLES
where table_schema=' ' and table_name=' ';
2.クエリmysqlでロックされたスレッド
SELECT * FROM information_schema.innodb_trx where trx_state = 'LOCK WAIT'\G
3.mysqldump sqlスクリプトのエクスポート時に1つ以上のテーブルを除外
mysqldump -u -p --ignore-table= . --ignore-table= . > .sql
4.mysqldump where条件に基づいて、あるテーブルの条件に合致するデータをエクスポートする
mysqldump -u -p --where=' ' > .sql
5.mysqldump指定されたテーブルの構造とデータのエクスポート
mysqldump -u -p --tables 1 2 > .sql