日期:2014-05-16  浏览次数:20783 次

USER_TAB_COLS和USER_TAB_COLUMNS两个视图有什么区别

转自:http://blog.csdn.net/yanleigis/article/details/2916096?

看oracle的元数据,

--by yl?landgis@126.com,yanleigis@21cn.com?2008.9.12

create or replace view sys.user_tab_columns as
select TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,
?????? DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,
?????? DEFAULT_LENGTH, DATA_DEFAULT, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,
?????? DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,
?????? CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,
?????? GLOBAL_STATS, USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,
?????? V80_FMT_IMAGE, DATA_UPGRADED, HISTOGRAM
? from USER_TAB_COLS
?where HIDDEN_COLUMN = 'NO'

HIDDEN_COLUMN 字段来源

SQL> CREATE TABLE yl (id integer,name varchar2(32));

Table created

SQL> INSERT INTO yl SELECT? rownum,'yanleigis' || LPAD(ROWNUM,2,'0') FROM DUAL CONNECT BY ROWNUM<=11;

11 rows inserted

SQL> commit;

Commit complete

SQL> CREATE INDEX idx_Name_yl ON yl(SUBSTR(name,4));

Index created

SQL> DESC yl;
Name Type???????? Nullable Default Comments?
---- ------------ -------- ------- --------?
ID?? INTEGER????? Y?????????????????????????
NAME VARCHAR2(32) Y????????????????????????

SQL> select * from yl;

???????????????????????????????????? ID NAME
--------------------------------------- --------------------------------
????????????????????????????????????? 1 yanleigis01
????????????????????????????????????? 2 yanleigis02
????????????????????????????????????? 3 yanleigis03
????????????????????????????????????? 4 yanleigis04
????????????????????????????????????? 5 yanleigis05
????????????????????????????????????? 6 yanleigis06
????????????????????????????????????? 7 yanleigis07
????????????????????????????????????? 8 yanleigis08
????????????????????????????????????? 9 yanleigis09
???????????????????????????????????? 10 yanleigis10
???????????????????????????????????? 11 yanleigis11

11 rows selected

SQL> SELECT COLUMN_NAME,HIDDEN_COLUMN FROM user_TAB_COLS WHERE TABLE_NAME='YL';

COLUMN_NAME??????????????????? HIDDEN_COLUMN
------------------------------ -------------
ID???????????????????????????? NO
NAME?????????????????????????? NO
SYS_NC00003$?????????????????? YES

SQL>? SELECT SYS_NC00003$ ,id,name FROM yl;

SYS_NC00003$??????????????????????????????????????????????????????????????????????????????????? ID NAME
---------------------- --------------------------------------- --------------------------------
leigis01????????????????