履歴表のヘルパー関数
履歴表のいくつかの列には、マッピングされた値とビット・マスクを使用するデータが格納されます。 以下のヘルパー関数を履歴照会内で使用して、これらの内部値のさらに多くの読み込み可能なテキスト値およびストリングを返すことができます。
関数 | 説明 | 戻り値 |
---|---|---|
FORMAT_QUERY_STATUS () | この関数を使用して、$hist_query_epilog.status 列データのすべてのテキスト・ストリング・バージョンを表示します。 | 以下のいずれかのステータス値:
|
FORMAT_PLAN_STATUS () | この関数を使用して、$hist_plan_epilog.status 列データのテキスト・ストリング・バージョンを表示します。 | 以下のいずれかのステータス値:
|
FORMAT_TABLE_ACCESS() | この関数を使用して、$hist_table_access.usage 列データのすべてのビット・セットのテキスト・ストリング・バージョンを表示します。 | 以下の 1 つ以上の値をコンマで区切ったリスト:
|
FORMAT_COLUMN_ACCESS() | この関数を使用して、$hist_column_access.usage 列データのすべてのビット・セットのテキスト・ストリング・バージョンを表示します。 | 以下の 1 つ以上の値をコンマで区切ったリスト:
|
以下のサンプル照会は、これらのヘルパー関数の使用方法を示しています。
SELECT
substr (querytext, 1, 50) as QUERY,
format_query_status (status) as status,
tb.tablename,
format_table_access (tb.usage),
co.columnname,
format_column_access (co.usage)
from "$hist_query_prolog_3" qp
inner join
"$hist_query_epilog_3" qe using (npsid, npsinstanceid, opid)
inner join
"$hist_table_access_3" tb using (npsid, npsinstanceid, opid)
inner join
"$hist_column_access_3" co using (npsid, npsinstanceid, opid)
where
exists (select tb.dbname
from "$hist_table_access_3" tb
where tb.npsid = qp.npsid and
tb.npsinstanceid = qp.npsinstanceid and
tb.opid = qp.opid and
tb.tablename in (^nation^, ^orders^, ^part^,
^partsupp^, ^supplier^, ^lineitem^,
^region^))
and tb.tableid = co.tableid;