#author("2024-08-26T01:31:36+00:00","default:editor","editor")
#author("2026-01-16T06:05:23+00:00","default:editor","editor")
[[SAGA]]

#contents

* 科研費申請と実績報告書用データ(2024/08/26) [#o48a202e]
- 報告書用データベース
 kakenhi_R2
 kakenhi_R4

* 二つのテーブルを比較して差分を表示(2018/09/20) [#m2f4df58]
- データの更新前後のテーブルを比較する場合に便利。
 select * from saga_uptest.abundance b where not exists (select a.Entry, a.Object from saga_LG_uptest.abundance a where a.Entry = b.Entry and a.Object = b.Object ) order by Entry, Object;
- カタログの更新チェック
 select * from saga_LG_uptest.object_catalog b where not exists (select a.Entry, a.Object from saga_LG.object_catalog a where a.Entry = b.Entry and a.Object = b.Object ) order by Entry, Object;

* MySQLでテーブルの数をカウント(2017/11/21) [#e8269f2c]
- 一時テーブルのカウントに利用。
 select count(*) from `information_schema`.`tables` where `table_schema` = 'suda_tmp';
- おまけ:テーブルのレコード数をカウント。
 select table_name, table_rows from information_schema.TABLES
 where table_schema = 'suda_tmp';

* テーブル名変更 [#rf9d79a1]
- alter table ... renameを使う
 ALTER TABLE tbl_name RENAME [TO] new_tbl_name;

* データベースのコピー [#j3fb4459]
- mysqldumpを使う。
 mysqldump -u username -p db_name > db_name.sql
 mysql -u username -p db_name2 < db_name.sql
-- db_name2は.sql内部で指定しているので不要(2026/01/16)

* MySQLテーブルが作成された日時を取得。(2016/07/08) [#ffa9a038]
 select table_schema, table_name, create_time from information_schema.tables where table_schema = 'suda_tmp' order by create_time;
- 使用例: 最新データの登録日時
  select table_schema, table_name, create_time from information_schema.tables where table_schema = 'saga_uptest' order by create_time;


* MySQLテーブルが更新された日時を取得。(2024/05/06) [#z6acc09d]
 select table_schema, table_name, update_time from information_schema.tables where table_schema = 'DB名' and table_name = 'テーブル名'\G
- table_schema = saga_LG_uptest, table_name = object_catlogではupdate_timeが登録されていないので注意。

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS