- 追加された行はこの色です。
- 削除された行はこの色です。
MySQL 固有の便利なSQLのまとめ
#author("2022-06-07T01:19:01+00:00","default:admin","admin")
*スキーマ [#sb56edb0]
-[[MySQLでインデックスが貼られているかを確認するSQL:https://qiita.com/pugiemonn/items/2edf5d7967fb45dd5196]]
show index from [テーブル名];
*日時 [#j2a60374]
-[[日時別の集計(日ごと, 月ごと, 曜日ごと):https://www.wakuwakubank.com/posts/667-mysql-sum-day/]]
-曜日別
select date_format(insert_date, '%w') as day_of_week, count(*) from test_table group by day_of_week;
-時間帯別
select date_format(insert_date, '%H') as hour, count(*) from test_table group by hour;
* [[DELETE:http://dev.mysql.com/doc/refman/5.1/ja/delete.html]] [#r42c5387]
** LIMIT row_count オプション [#u1c8a307]
-MySQL 特有
-コントロールがクライアントに戻される前に、削除されるべき最大行数をサーバに伝える
-与えられた DELETE ステートメントに時間がかかりすぎない事を保障します
-影響される行数が LIMIT 値よりも少なくなるまで DELETE ステートメントを繰り返す