2019-05-06から1日間の記事一覧

DBチューニングアドバイザ

DB

Oracle ORAchkhttps://www.oracle.com/technetwork/jp/database/articles/shibacho/index-2491041-ja.html MySQL MySQLTunerhttps://www.e-agency.co.jp/column/20121220.html cd /usr/share/wget -O MySQLTuner.zip https://github.com/rackerhacker/MySQLT…

SQLチューニングアドバイザ

DB

Oracle SQLチューニングアドバイザhttps://docs.oracle.com/cd/E57425_01/121/TGSQL/tgsql_sqltune.htm#GUID-8E1A39CB-A491-4254-8B31-9B1DF7B52AA1 MySQL 調べたかぎり、見つからない PostgreSQL dexterhttps://dev.classmethod.jp/server-side/db/guess-po…

チェックポイント

DB

Oracle ALTER SYSTEM CHECKPOINT; MySQL 調べたかぎり、見つからない PostgreSQL CHECKPOINT; SQL Server CHECKPOINT

不可視索引

DB

Oracle select table_name,index_name,visibility from all_indexes where index_name = 'IND1'; alter index ind1 visible;alter index ind1 invisible; MySQL (8.0)から実装 show index from tab1 where key_name = 'ind1'\G alter table tab1 alter index…

コメント(テーブル、カラム)

DB

Oracle select * from ALL_TAB_COMMENTS where table_name = 'TAB1';select * from ALL_COL_COMMENTS where table_name = 'TAB1' and column_name = 'COL1'; comment on table test.tab1 is 'comment on tab1';comment on column test.tab1.col1 is 'comment…

WAL中身確認

DB

Oracle LogMiner https://docs.oracle.com/cd/E57425_01/121/SUTIL/GUID-40619B3B-8BDF-4D90-B924-5A0F8A631F98.htm ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; SELECT NAME FROM V$ARCHIVED_LOG WHERE FIRST_TIME = (SELECT MAX(FIRST_TIME) FROM V$ARCHIV…

強制パラメータ化

DB

Oracle ALTER SESSION SET CURSOR_SHARING=FORCE; select sum(col1) from test.tab1 where col2 = 0;select * from table(dbms_xplan.display_cursor());select sum(col1) from test.tab1 where col2 = 123;select * from table(dbms_xplan.display_cursor()…

select for update

DB

Oracle select * from tab1 where col1 = 1 for update; MySQL select * from tab1 where col1 = 1 for update; 行および関連付けられたすべてのエントリをロックします。この動作は、これらの行に UPDATE ステートメントを発行した場合と同じです。 select …

デッドロック

DB

Oracle create table tab1(col1 int primary key,col2 int);create table tab2(col1 int primary key,col2 int); insert into tab1 values(1,1);insert into tab2 values(1,1);commit; --tx1update tab1 set col2 = 11 where col1 = 1; --tx2update tab2 set…

データベースチェック

DB

Oracle (19c) rman target /validate database; select name from v$hm_check where internal_check = 'N'; exec dbms_hm.run_check('Dictionary Integrity Check','test006'); set long 400000set longchunksize 400000set pages 1000set lines 1000 select…

変更追跡

DB

Oracle フラッシュバックデータアーカイブ(Oracle Total Recall) select flashback_on from v$database; alter system set db_recovery_file_dest_size = 10G;alter system set db_recovery_file_dest='/u01/app/oracle/oradata/orcl'; shutdown immediatest…

行ロック確認

DB

Oracle create table lock_test ( id int primary key, name varchar2(32) not null, age int not null); insert into lock_test(id,name, age) values(1,'tanaka', 20);insert into lock_test(id,name, age) values(2,'suzuki', 30);insert into lock_test(…

ロギング一時停止

DB

Oracle alter table tab1 nologging; alter index ind1 nologging; ※ダイレクト・パス・インサート によるデータの登録処理など一部処理だけが対象 MySQL (8.0.33) (1) バイナリログ set sql_log_bin = 0; (2) redoログ https://dev.mysql.com/doc/refman/8.…

主キーと外部キーの追加

DB

Oracle create table tab10(col1 int,col2 int);create table tab11(col1 int,col2 int); alter table tab10 add constraint tab10pk primary key(col1);alter table tab11 add constraint tab11pk primary key(col1); alter table tab11 add constraint tab…

インデックス断片化の確認と解消

DB

Oracle http://tihiro.hatenablog.com/entry/2017/08/31/120917 create table tab1(col1 int);create index ind11 on tab1(col1);insert into tab1 values(1);insert into tab1 values(2);insert into tab1 values(3);commit; --インデックスの断片化を確認 …

データマスキング

DB

Oracle BEGINDBMS_REDACT.ADD_POLICY(object_schema => 'test', object_name => 'tab1', column_name => 'col1',policy_name => 'pol1', function_type => DBMS_REDACT.FULL,expression => '1=1');END;/ MySQL コミュニティ版にはない模様 エンタープライズ…

バックアップ暗号化

DB

Oracle --バックアップの透過的暗号化暗号化の項を参照し、透過的データ暗号化を構成する CONFIGURE ENCRYPTION FOR DATABASE ON;backup database plus archivelog; --バックアップのパスワード暗号化SET ENCRYPTION ON IDENTIFIED BY oracle ONLY;backup da…

バックアップ圧縮

DB

Oracle backup as compressed backupset database plus archivelog; MySQL mysqldumpとgzipをパイプで繋ぐとディスクを節約できる mysqldump -u root -h 192.168.137.50 test -p --quick --master-data=2 --flush-logs --single-transaction --triggers --ro…

行数制限

DB

Oracle select * from tab1 order by col1 fetch first 3 rows only;select * from tab1 order by col1 offset 2 rows fetch next 3 rows only; MySQL select * from tab1 order by col1 limit 2; select * from tab1 order by col1 limit 0 , 2;select * fr…

テンポラリテーブル

DB

Oracle --トランザクション終了時にデータ削除。テーブルは永続的create global temporary table ttab1(col1 int) on commit delete rows; --セッション終了時にデータ削除。テーブルは永続的create global temporary table ttab2(col1 int) on commit prese…

コメント

DB

Oracle -- This is commentSELECT 1 /* this is an in-line comment */ + 1 from dual; MySQL 「#」文字から行末まで「-- 」シーケンスから行末まで/* シーケンスから次の */ シーケンスまで SELECT 1+1; # This comment continues to the end of lineSELECT…

メモリ構造

DB

Oracle システム・グローバル領域(SGA)-データベース・バッファ・キャッシュ-インメモリー列ストア-REDOログ・バッファ-共有プール--ライブラリ・キャッシュ--データ・ディクショナリ・キャッシュ--サーバー結果キャッシュ--予約プール-ラージ・プール-Java…

ヌルの扱い

DB

Oracle ヌルと空文字は同じ MySQL ヌルと空文字は異なる create table tab15(col1 int,col2 varchar(10));insert into tab15 values(1,'');insert into tab15 values(2,NULL); select * from tab15; select * from tab15 where col2 = '';select * from tab1…

縦表示

DB

Oracle ネイティブには存在しない MySQL show processlist;show processlist\G PostgreSQL \x SQL Server ネイティブには存在しない

ログインエイリアス

DB

Oracle vim tnsnames.ora orcl= (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=mmm050)(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=orcl.example.com))) MySQL mysql_config_editor set --login-path=test --host=localhost --user=root --password mysql_con…

文字列連結

DB

Oracle select 'Hello' || ' World' from dual;select concat('Hello',' World') from dual; MySQL select CONCAT('A','B'); PostgreSQL select 'Hello' || ' World';select concat('Hello',' World'); SQL Server select 'Hello' + ' World' ;select concat…

シャーディング

DB

Oracle (12cR2)CentOS7 mmm181: シャード・カタログ シャード・ディレクタmmm182: シャード・ノードmmm183: シャード・ノード メモリ:2Gディスク:40G --1.OS設定[mmm181,mmm182,mmm183]yum update -y systemctl stop firewalldsystemctl disable firewalldse…

データ型

DB

Oracle intcharvarchar2date select data_type,count(*)from dba_tab_columnswhere owner= 'TEST'group by data_typeorder by data_type; MySQL https://dev.mysql.com/doc/refman/5.6/ja/data-type-overview.html intcharvarchardatetime create table tab1…

テーブル名インデックス名カラム名の最大長

DB

MySQL (8.0.22)https://dev.mysql.com/doc/refman/5.6/ja/identifiers.html 64 drop table tab1234567890123456789012345678901234567890123456789012345678901;create table tab1234567890123456789012345678901234567890123456789012345678901(col12345678…