1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Oracle Databaseの拡張統計の作成

1
Last updated at Posted at 2026-09-20

ピリオドを区切り文字としてテーブルemployeesbkのphone_number列の2番目の要素に対して拡張統計を作成する。

begin
  DBMS_STATS.SET_TABLE_PREFS('hr','employeesbk','METHOD_OPT','FOR ALL COLUMNS SIZE AUTO,FOR COLUMNS SIZE AUTO (REGEXP_SUBSTR(phone_number, ''[^.]+'', 1, 2))');
end;
/

設定を確認する

select * from DBA_TAB_STAT_PREFS where owner='HR' and table_name='EMPLOYEESBK';

image.png

テーブルemployeesbkの統計情報を収集する。

BEGIN
  dbms_stats.gather_table_stats(ownname => 'HR', tabname => 'EMPLOYEESBK');
END;
/

隠し列が作成されたことを確認する

select OWNER,TABLE_NAME,COLUMN_NAME,DATA_TYPE,DATA_DEFAULT,NUM_DISTINCT,LAST_ANALYZED from dba_tab_cols where owner='HR' and table_name = 'EMPLOYEESBK';

image.png

列単位の統計情報を確認する。

select * from dba_tab_col_statistics where owner='HR' and table_name = 'EMPLOYEESBK';

image.png
以上

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?