首页 > 数据库 >oracle表字段设置为unused的相关知识

oracle表字段设置为unused的相关知识

时间:2022-11-04 21:02:26浏览次数:44  
标签:10 12 04 09 表字 unused TEST 2022 oracle

文档课题:oracle表字段设置为unused的相关知识.
数据库:oracle 19.3
表emp_test相关信息.
SQL> select table_name,column_name,data_type,data_length,data_precision,data_scale,to_char(last_analyzed,'yyyy-mm-dd hh24:mi:ss') from user_tab_columns where table_name='EMP_TEST'

TABLE_NAME COLUMN_NAME DATA_TYPE DATA_LENGTH DATA_PRECISION DATA_SCALE TO_CHAR(LAST_ANALYZ
--------------- -------------------- --------------- ----------- -------------- ---------- -------------------
EMP_TEST EMPLOYEE_ID NUMBER 22 6 0 2022-09-04 12:10:17
EMP_TEST FIRST_NAME VARCHAR2 9 2022-09-04 12:10:17
EMP_TEST LAST_NAME VARCHAR2 25 2022-09-04 12:10:17
EMP_TEST EMAIL VARCHAR2 25 2022-09-04 12:10:17
EMP_TEST PHONE_NUMBER VARCHAR2 20 2022-09-04 12:10:17
EMP_TEST HIRE_DATE TIMESTAMP(6) 11 6 2022-09-04 12:10:17
EMP_TEST JOB_ID VARCHAR2 12 2022-09-04 12:10:17
EMP_TEST SALARY NUMBER 22 8 2 2022-09-04 12:10:17
EMP_TEST COMMISSION_PCT NUMBER 22 2 2 2022-09-04 12:10:17
EMP_TEST MANAGER_ID NUMBER 22 6 0 2022-09-04 12:10:17
EMP_TEST DEPARTMENT_ID NUMBER 22 4 0 2022-09-04 12:10:17

11 rows selected.
SQL> desc emp_test
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
EMPLOYEE_ID NUMBER(6)
FIRST_NAME VARCHAR2(9)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL TIMESTAMP(6)
JOB_ID NOT NULL VARCHAR2(12)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
设置email字段为unused.
SQL> alter table emp_test set unused (email);

Table altered.
再次查询,email字段不再显示.
SQL> select table_name,column_name,data_type,data_length,data_precision,data_scale,to_char(last_analyzed,'yyyy-mm-dd hh24:mi:ss') from user_tab_columns where table_name='EMP_TEST'
2*

TABLE_NAME COLUMN_NAME DATA_TYPE DATA_LENGTH DATA_PRECISION DATA_SCALE TO_CHAR(LAST_ANALYZ
--------------- -------------------- --------------- ----------- -------------- ---------- -------------------
EMP_TEST EMPLOYEE_ID NUMBER 22 6 0 2022-09-04 12:10:17
EMP_TEST FIRST_NAME VARCHAR2 9 2022-09-04 12:10:17
EMP_TEST LAST_NAME VARCHAR2 25 2022-09-04 12:10:17
EMP_TEST PHONE_NUMBER VARCHAR2 20 2022-09-04 12:10:17
EMP_TEST HIRE_DATE TIMESTAMP(6) 11 6 2022-09-04 12:10:17
EMP_TEST JOB_ID VARCHAR2 12 2022-09-04 12:10:17
EMP_TEST SALARY NUMBER 22 8 2 2022-09-04 12:10:17
EMP_TEST COMMISSION_PCT NUMBER 22 2 2 2022-09-04 12:10:17
EMP_TEST MANAGER_ID NUMBER 22 6 0 2022-09-04 12:10:17
EMP_TEST DEPARTMENT_ID NUMBER 22 4 0 2022-09-04 12:10:17

10 rows selected.
通过数据字典user_unused_col_tabs查出某表有几个字段被设置为unused.
SQL> desc user_unused_col_tabs;
Name Null? Type
----------------------- -------- ----------------
TABLE_NAME NOT NULL VARCHAR2(128)
COUNT NUMBER
SQL> select * from user_unused_col_tabs;

TABLE_NAME COUNT
--------------- ----------
EMP_TEST 1

说明:如上所示,表emp_test有1个字段被设置为unused,但目前未找到查询具体哪个字段被设置为unused的视图.
删除unused字段.
SQL> alter table emp_test drop unused column;

Table altered.

SQL> select * from user_unused_col_tabs;

no rows selected


标签:10,12,04,09,表字,unused,TEST,2022,oracle
From: https://blog.51cto.com/u_12991611/5824752

相关文章