查詢字段區分度,NUM_DISTINCT值越大,惟一度越高,區分度越大spa
SELECT column_name, DECODE (t.data_type, 'NUMBER', t.data_type || '(' || DECODE (t.data_precision, NULL, t.data_length || ')', t.data_precision || ',' || t.data_scale || ')' ), 'DATE', t.data_type, 'LONG', t.data_type, 'LONG RAW', t.data_type, 'ROWID', t.data_type, 'MLSLABEL', t.data_type, t.data_type || '(' || t.data_length || ')' ) || ' ' || DECODE (t.nullable, 'N', 'NOT NULL', 'n', 'NOT NULL', NULL) col, num_distinct, density FROM dba_tab_columns t WHERE table_name = UPPER ('&Table_name') AND owner = UPPER (NVL ('&Owner', USER));