セッション変数には、システム変数とユーザー変数があります。本記事では、ODP上で指定されたクライアントセッションのセッション変数を確認する方法について説明します。
操作手順
sysテナントとユーザーテナントは、SHOW PROXYSESSION VARIABLESステートメントを使用して指定されたクライアントセッションのセッション変数を確認できます。
ODP経由でOceanBaseデータベースに接続します。
接続例は以下のとおりです:
obclient -h10.xx.xx.xx -uusername@obtenant#obdemo -P2883 -p****** -c -A oceanbaseODP経由でデータベースに接続する方法の詳細な操作ガイドについては、OBClientを使用してOceanBaseテナントに接続する (MySQLモード)およびOBClientを使用してOceanBaseテナントに接続する (Oracleモード)を参照してください。
指定されたクライアントセッションのセッション変数を確認します。
SHOW PROXYSESSION VARIABLES [ALL] id [LIKE 'xx'];パラメータの説明:
ALLパラメータがない場合、指定されたクライアントセッションのローカルセッション変数 (変更されたシステム変数とユーザー変数を含む) を表示します。ALLパラメータがある場合、指定されたクライアントセッションのすべてのセッション変数 (すべてのシステム変数とユーザー変数を含む) を表示します。idはcs_idまたはconnection_idのいずれかであり、表示結果は同じです。cs_idはODP内部で各クライアントに割り当てられるid番号であり、connection_idはOceanBaseデータベース全体で各クライアントに割り当てられるid番号です。MySQLモードの
connection_idはSELECT CONNECTION_ID();ステートメントで取得し、Oracleモードのconnection_idはSHOW FULL PROCESSLIST;ステートメントで取得します。likeはあいまい一致であり、'%'と'_'をサポートします。
例:
MySQLモードOracleモードcs_idまたはconnection_idを取得します。次のステートメントを実行して
cs_idを取得します。SHOW PROXYSESSION;クエリ結果は次のとおりで、返される結果の
Idがcs_idです。+----------------------+-------+----------+----------+------+----------------------+------+-------------+-------------------+-------------------+-------+-------+-----------+ | proxy_sessid | Id | Cluster | Tenant | User | Host | db | trans_count | svr_session_count | state | tid | pid | using_ssl | +----------------------+-------+----------+----------+------+----------------------+------+-------------+-------------------+-------------------+-------+-------+-----------+ | 12402504630519660559 | 65149 | test420 | mysql001 | root | 100.xx.xx.xx:46069 | NULL | 0 | 1 | MCS_ACTIVE_READER | 76286 | 76286 | 0 | +----------------------+-------+----------+----------+------+----------------------+------+-------------+-------------------+-------------------+-------+-------+-----------+ 1 row in setまたは、次のステートメントを実行して
connection_idを取得します。SELECT CONNECTION_ID();次のような結果が返されます。
+-----------------+ | CONNECTION_ID() | +-----------------+ | 3221593149 | +-----------------+ 1 row in set指定されたClientセッションのローカルセッション変数を表示します。
SHOW PROXYSESSION VARIABLES 65149;または
SHOW PROXYSESSION VARIABLES 3221593149;クエリ結果は次のとおりです:
+-----------------------------------+--------------+-----------------+--------------------+-----------------------------------------------+ | variable_name | value | info | modified_type | sys_variable_flag | +-----------------------------------+--------------+-----------------+--------------------+-----------------------------------------------+ | ob_proxy_global_variables_version | 0 | changed sys var | cold modified vars | && invisible && session_scope && readonly | | ob_proxy_user_privilege | 133009965054 | changed sys var | cold modified vars | && invisible && session_scope && readonly | | ob_capability_flag | 916303 | changed sys var | cold modified vars | && invisible && session_scope && readonly | | ob_enable_transmission_checksum | 1 | changed sys var | cold modified vars | && global_scope && session_scope | | character_set_database | 45 | changed sys var | cold modified vars | && global_scope && session_scope && nullable | | collation_database | 45 | changed sys var | cold modified vars | && global_scope && session_scope && nullable | | _min_cluster_version | '4.2.0.0' | user var | cold modified vars | | +-----------------------------------+--------------+-----------------+--------------------+-----------------------------------------------+ 7 rows in set指定されたClientセッションのすべてのセッション変数を表示します。
SHOW PROXYSESSION VARIABLES ALL 65149 LIKE '%id%';または
SHOW PROXYSESSION VARIABLES ALL 3221593149 LIKE '%id%';クエリ結果は次のとおりです:
+--------------------------------------+----------------------------------------+---------+------------------------------+--------------------------------------------+ | variable_name | value | info | modified_type | sys_variable_flag | +--------------------------------------+----------------------------------------+---------+------------------------------+--------------------------------------------+ | last_insert_id | 0 | sys var | last insert id modified vars | && session_scope | | identity | 0 | sys var | cold modified vars | && session_scope | | server_id | 1 | sys var | cold modified vars | &&global_scope | | query_cache_wlock_invalidate | 0 | sys var | cold modified vars | && global_scope && session_scope | | server_uuid | 'd72b5d0d-2c50-11ee-b1de-2646ab385e11' | sys var | cold modified vars | && global_scope && readonly | | ob_org_cluster_id | 0 | sys var | cold modified vars | && session_scope | | ob_statement_trace_id | 'Y0-0' | sys var | cold modified vars | && invisible && session_scope && readonly | | ob_trx_idle_timeout | 86400000000 | sys var | cold modified vars | && global_scope && session_scope | | tracefile_identifier | '' | sys var | cold modified vars | && session_scope | | validate_password_check_user_name | 0 | sys var | cold modified vars | && global_scope | | validate_password_length | 0 | sys var | cold modified vars | && global_scope | | validate_password_mixed_case_count | 0 | sys var | cold modified vars | && global_scope | | validate_password_number_count | 0 | sys var | cold modified vars | && global_scope | | validate_password_policy | 0 | sys var | cold modified vars | && global_scope | | validate_password_special_char_count | 0 | sys var | cold modified vars | && global_scope | +--------------------------------------+----------------------------------------+---------+------------------------------+--------------------------------------------+ 15 rows in set
cs_idまたはconnection_idを取得します。次のステートメントを実行して
cs_idを取得します。SHOW PROXYSESSION;クエリ結果は次のとおりです。返される結果の
Idがcs_idになります。+----------------------+-------+----------+-----------+------+----------------------+------+-------------+-------------------+-------------------+-------+-------+-----------+ | proxy_sessid | Id | Cluster | Tenant | User | Host | db | trans_count | svr_session_count | state | tid | pid | using_ssl | +----------------------+-------+----------+-----------+------+----------------------+------+-------------+-------------------+-------------------+-------+-------+-----------+ | 12402504630519660558 | 65141 | test420 | oracle001 | sys | 100.xx.xx.xx:59648 | SYS | 0 | 1 | MCS_ACTIVE_READER | 76286 | 76286 | 0 | +----------------------+-------+----------+-----------+------+----------------------+------+-------------+-------------------+-------------------+-------+-------+-----------+ 1 row in set次のステートメントを実行して
connection_idを取得します。SHOW FULL PROCESSLIST;次のような結果が返されます。返される結果の
idがconnection_idになります。+------------+------+-----------+---------------------+------+---------+------+--------+-----------------------+---------------+------+ | ID | USER | TENANT | HOST | DB | COMMAND | TIME | STATE | INFO | IP | PORT | +------------+------+-----------+---------------------+------+---------+------+--------+-----------------------+---------------+------+ | 3221583071 | SYS | oracle001 | 172.xx.xx.xx:45343 | SYS | Query | 0 | ACTIVE | SHOW FULL PROCESSLIST | 172.xx.xx.64 | 2881 | +------------+------+-----------+---------------------+------+---------+------+--------+-----------------------+---------------+------+ 1 row in set指定されたClientセッションのローカルセッション変数を確認します。
SHOW PROXYSESSION VARIABLES 65141;または
SHOW PROXYSESSION VARIABLES 3221583071;クエリ結果は次のとおりです:
+-----------------------------------+--------------+-----------------+--------------------+-----------------------------------------------+ | variable_name | value | info | modified_type | sys_variable_flag | +-----------------------------------+--------------+-----------------+--------------------+-----------------------------------------------+ | autocommit | 0 | changed sys var | hot modified vars | && global_scope && session_scope | | character_set_connection | 46 | changed sys var | cold modified vars | && global_scope && session_scope && nullable | | character_set_database | 46 | changed sys var | cold modified vars | && global_scope && session_scope && nullable | | character_set_server | 46 | changed sys var | cold modified vars | && global_scope && session_scope && nullable | | collation_connection | 46 | changed sys var | cold modified vars | && global_scope && session_scope && nullable | | collation_database | 46 | changed sys var | cold modified vars | && global_scope && session_scope && nullable | | collation_server | 46 | changed sys var | cold modified vars | && global_scope && session_scope && nullable | | sql_mode | 2151677954 | changed sys var | cold modified vars | && global_scope && session_scope | | group_concat_max_len | 32767 | changed sys var | cold modified vars | && global_scope && session_scope | | ob_proxy_global_variables_version | 0 | changed sys var | cold modified vars | && invisible && session_scope && readonly | | ob_proxy_user_privilege | 133009965054 | changed sys var | cold modified vars | && invisible && session_scope && readonly | | ob_capability_flag | 916303 | changed sys var | cold modified vars | && invisible && session_scope && readonly | | ob_enable_transmission_checksum | 1 | changed sys var | cold modified vars | && global_scope && session_scope | | _min_cluster_version | '4.2.0.0' | user var | cold modified vars | | +-----------------------------------+--------------+-----------------+--------------------+-----------------------------------------------+ 14 rows in set指定されたClientセッションのすべてのセッション変数を確認します。
SHOW PROXYSESSION VARIABLES ALL 65141 LIKE '%id%';または
SHOW PROXYSESSION VARIABLES ALL 3221583071 LIKE '%id%';クエリ結果は次のとおりです:
+--------------------------------------+----------------------------------------+---------+------------------------------+--------------------------------------------+ | variable_name | value | info | modified_type | sys_variable_flag | +--------------------------------------+----------------------------------------+---------+------------------------------+--------------------------------------------+ | last_insert_id | 0 | sys var | last insert id modified vars | && session_scope | | identity | 0 | sys var | cold modified vars | && session_scope | | server_id | 1 | sys var | cold modified vars | &&global_scope | | query_cache_wlock_invalidate | 0 | sys var | cold modified vars | && global_scope && session_scope | | server_uuid | 'd72b5d0d-2c50-11ee-b1de-2646ab385e11' | sys var | cold modified vars | && global_scope && readonly | | ob_org_cluster_id | 0 | sys var | cold modified vars | && session_scope | | ob_statement_trace_id | 'Y0-0' | sys var | cold modified vars | && invisible && session_scope && readonly | | ob_trx_idle_timeout | 86400000000 | sys var | cold modified vars | && global_scope && session_scope | | tracefile_identifier | '' | sys var | cold modified vars | && session_scope | | validate_password_check_user_name | 0 | sys var | cold modified vars | && global_scope | | validate_password_length | 0 | sys var | cold modified vars | && global_scope | | validate_password_mixed_case_count | 0 | sys var | cold modified vars | && global_scope | | validate_password_number_count | 0 | sys var | cold modified vars | && global_scope | | validate_password_policy | 0 | sys var | cold modified vars | && global_scope | | validate_password_special_char_count | 0 | sys var | cold modified vars | && global_scope | +--------------------------------------+----------------------------------------+---------+------------------------------+--------------------------------------------+ 15 rows in set
各フィールドの意味は以下の表のとおりです:
フィールド 説明 variable_name 変数名 value 変数値 info 変数タイプ(ユーザー変数またはシステム変数) modified_type 変数タイプ(変更頻度による分類) sys_variable_flag システム変数範囲
関連ドキュメント
システム変数の詳細については、構成パラメータとシステム変数の概要を参照してください。