How can you tell which columns are unused in ALL_TAB_COLS?

后端 未结 2 1925
野的像风
野的像风 2021-01-14 05:18

When you query the ALL_TAB_COLS view on Oracle 9i, it lists columns marked as UNUSED as well as the \'active\' table columns. There doesn\'t seem to be a field that explicit

2条回答
  •  逝去的感伤
    2021-01-14 06:03

    Try using ALL_TAB_COLUMNS instead of ALL_TAB_COLS. In Oracle 11.2 I find that unused columns appear in ALL_TAB_COLS (though renamed) but not in ALL_TAB_COLUMNS.

    I created a table like this:

    create table t1 (c1 varchar2(30), c2 varchar2(30);
    

    Then set c2 unused:

    alter table t1 set unused column c2;
    

    Then I see:

    select column_name from all_tab_cols where owner='ME' and table_name='T1';
    
    COLUMN_NAME
    -----------
    C1
    SYS_C00002_10060107:25:40$
    
    select column_name from all_tab_columns where owner='ME' and table_name='T1';
    
    COLUMN_NAME
    -----------
    C1
    

提交回复
热议问题