2021-07-01から1ヶ月間の記事一覧

データファイル拡張できないときの挙動

DB

MySQL (8.0.22)https://dev.mysql.com/doc/refman/8.0/ja/innodb-create-table-external.html file-per-table テーブルスペースまたは一般テーブルスペースが DATA DIRECTORY = 句を使用して作成された場合、.ibd ファイルは通常のデータディレクトリ外の指…

{Aurora}Amazon Aurora データベースログファイルの操作

AWS

Aurora MySQL -- データベースログファイルの表示とリスト化aws rds describe-db-log-files --db-instance-identifier cluster01-instance-1 -- データベースログファイルのダウンロードaws rds download-db-log-file-portion \--db-instance-identifier clu…

{Aurora}Amazon RDS イベント通知にサブスクライブする

AWS

-- SNSトピック作成 aws sns list-topicsaws sns list-subscriptions aws sns create-topic --name topic01 aws sns subscribe --topic-arn arn:aws:sns:ap-northeast-1:999999999999:topic01 --protocol email --notification-endpoint admin@example.com -…

{Aurora}データベースアクティビティストリームの開始

AWS

Aurora MySQL では、db.t2 インスタンスクラス または db.t3 インスタンスクラスではストリームを使用できません。Aurora PostgreSQL の場合、ストリームは db.r4 または db.r5 インスタンスクラスでのみ使用します。 アクティビティのストリームは、収集後…

{Aurora}Performance Insights API によるデータの取得

AWS

Performance Insights を使用するには、DB インスタンスで有効にします。 Aurora MySQL Aurora MySQL の Performance Schema を有効にすると、Performance Insights が提供する情報がより詳細になります。Aurora MySQL の場合、db.t2 または db.t3 DB インス…

{Aurora}特定の時点への DB クラスターの復元

AWS

-- 復元可能な直近の時間の確認aws rds describe-db-clusters | jq -c '.DBClusters[] | [.DBClusterIdentifier , .LatestRestorableTime]' -- クラスタの復元aws rds restore-db-cluster-to-point-in-time \--source-db-cluster-identifier cluster01 \--db…

{Aurora}Amazon S3 バケットへのスナップショットのエクスポート

AWS

サーバー側の暗号化用のKMSカスタマキー(CMK)が必要データは Apache Parquet 形式で一貫して圧縮され、保存されます。デフォルトでは、スナップショット内のすべてのデータがエクスポートされます。ただし、特定のデータベース、スキーマ、またはテーブルの…

{Aurora}DB クラスターのスナップショットからの復元

AWS

Amazon RDS は DB クラスタのストレージボリュームのスナップショットを作成し、個々のデータベースだけではなく、その DB クラスタ全体をバックアップします。 -- スナップショットの作成 aws rds create-db-cluster-snapshot \--db-cluster-identifier clu…

永続的統計情報取得タイミング

DB

MySQL (8.0.22)https://dev.mysql.com/doc/refman/8.0/ja/innodb-persistent-stats.html#innodb-persistent-stats-auto-recalc ①アナライズ実行時②閾値以上のデータ更新時(バックグラウンド非同期)③インデックス追加時 (確認)インデックス追加時に統計情報取…

トレースファイル

DB

MySQL なし Oracle (19c) select * from v$diag_info; PostgreSQL なし SQL Server (2019) select * from sys.traces; select * from sys.fn_trace_gettable('C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Log\log_34.trc',default); s…

{Aurora}Aurora レプリカでの Amazon Aurora Auto Scaling の使用

AWS

Aurora DB クラスタで Aurora Auto Scaling を使用する前に、まず、プライマリインスタンスと少なくとも 1 つの Aurora レプリカで Aurora DB クラスタを作成する必要があります。 Aurora MySQL -- スケーリングポリシーの追加 ---- ターゲットクラスタの登…

{Aurora}Aurora DB クラスターボリュームのクローン作成

AWS

Aurora MySQL aws rds restore-db-cluster-to-point-in-time \--source-db-cluster-identifier cluster01 \--db-cluster-identifier cluster01-clone \--restore-type copy-on-write \--use-latest-restorable-time aws rds describe-db-clusters \--db-clus…

delete文各種

DB

MySQLは複数テーブル同時削除の構文があるPostgreSQLは他テーブルを参照する拡張構文があるSQL Serverはサブクエリでの挙動が微妙のため、拡張構文を使用したほうがよい。 MySQL (8.0.22)https://qiita.com/toshiro3/items/b2e57a9867139bbdd439 drop table …

{Aurora}Amazon RDS Proxy による接続の管理

AWS

https://qiita.com/ttkn9a/items/2d325fc5e170721102d2 RDS Proxy は MySQL エンジンファミリーおよび PostgreSQL エンジンファミリーで使用できます。 特定のユーザーとしてプロキシを介して接続するには、シークレットに関連付けられているパスワードが、…

別テーブルの値を使用してupdate

DB

サブクエリ構文は4DBで使用可能MySQLは複数テーブル構文を使用可能。しかし複数行該当のエラーを検知できないPostgreSQLはupdate from構文を使用可能。しかし複数行該当のエラーを検知できないSQL Serverはupdate from構文を使用可能。しかし複数行該当のエ…

{Aurora}Amazon Aurora グローバルデータベースの使用

AWS

使用できるのは、db.r4かdb.r5のDBインスタンスクラスのみです。 -- Auroraクラスタの一覧aws rds describe-global-clustersaws rds describe-db-clustersaws rds describe-db-instances Aurora MySQL -- 1.Amazon Aurora グローバルデータベースの作成 aws …

{Aurora}Amazon Aurora Serverless v1 の使用

AWS

AuroraServerlessv1DBクラスターにパブリックIPアドレスを割り当てることはできません。VPC内からのみ、AuroraServerlessv1DBクラスターへのアクセスが可能です。 -- Auroraクラスタの一覧aws rds describe-db-clusters Aurora MySQL -- Aurora Serverlessク…

セッションで最後に生成したID値の取得

DB

MySQL (8.0.22) LAST_INSERT_ID()→最後に実行されたINSERTステートメントの結果としてAUTO_INCREMENTカラムに正常に挿入された最初の自動生成値を返します。 drop table tab1;create table tab1(col1 int not null auto_increment primary key,col2 int); in…

トランザクションのネスト

DB

MySQL (8.0.22)https://www.wakuwakubank.com/posts/203-mysql-transaction-nest/ トランザクションのネストをサポートしていない2つ目のstart transactionでコミットされる drop table tab1;create table tab1(col1 int); select * from tab1; start transa…

エラー発生時のロールバック範囲

DB

MySQL (8.0.22)https://dev.mysql.com/doc/refman/8.0/ja/innodb-error-handling.html エラー内容によって、文レベルのロールバックとなったり、トランザクションレベルのロールバックとなったりする デッドロックエラーはトランザクションレベルのロールバ…

SAVEPOINT

DB

MySQL (8.0.22)drop table tab1;create table tab1(col1 int); start transaction; insert into tab1 values(1); savepoint sp1; insert into tab1 values(2); rollback to sp1; commit; select * from tab1; Oracle (19c) drop table tab1 purge;create tab…

インデックスサイズ上限確認

DB

MySQL (8.0.24) show variables like 'innodb_page_size';show variables like '%char%'; drop table tab1; create table tab1(col1 varchar(100),col2 varchar(100),col3 varchar(100),col4 varchar(100),col5 varchar(100),col6 varchar(100),col7 varchar…

空コミットの影響

DB

MySQL (8.0.22) CPUコア数=2 drop table tab1;create table tab1 ( col1 int); alter table tab1 add constraint tab1pk primary key(col1); drop procedure proc1; delimiter //create procedure proc1(in x int)begin declare i int; set i = 0; start tra…

外部キー更新時挙動確認

DB

MySQL (8.0.22) drop table tab2;drop table tab1; create table tab1(col1 int,col2 int);create table tab2(col1 int,col2 int); alter table tab1 add constraint tab1pk primary key(col1);alter table tab2 add constraint tab2pk primary key(col1); a…

パーティションテーブルへの変更

DB

MySQL (8.0.22) https://dev.mysql.com/doc/refman/8.0/ja/alter-table-partition-operations.html drop table tab1; create table tab1( col1 int, col2 int, col3 int); alter table tab1 add constraint tab1pk primary key(col1); create index ind12 on…

エクスポートの中断・再開

DB

MySQL (8.0.22) 中断[Ctrl + Z] 確認jobs 再開fg %1 mysqldump -uroot -p test > test.dmp Oracle (19c) expdp test/test@pdb1 directory=ORA_DIR dumpfile=test.dmp logfile=test.log schemas=test reuse_dumpfiles=yes select * from dba_datapump_jobs; e…

エクスポートインポートによるデータファイルサイズ変化確認

DB

MySQL (8.0.22) 確認結果:データファイルサイズは変化なし -- データ準備drop tablespace tbs1;create tablespace tbs1 add datafile 'tbs1.ibd' engine=innodb; drop table tab1;drop table tab2;drop table tab3; create table tab1(col1 int primary key…