1.使用下面这个sql语句,可以获得我们非常常用的一些短小精悍的视图,这些视图通常是最常用的用户级别数据库对象
SELECT *
FROM dict
WHERE table_name NOT LIKE '%$%'
AND table_name NOT LIKE '%\_%' ESCAPE '\'
AND LENGTH (table_name) < 10
ORDER BY 1;
2.演示操作执行结果
sys@ora10g> SELECT *
2 FROM dict
3 WHERE table_name NOT LIKE '%$%'
4 AND table_name NOT LIKE '%\_%' ESCAPE '\'
5 AND LENGTH (table_name) < 10
6 ORDER BY 1;
TABLE_NAME COMMENTS
----------- ---------------------------------
CAT Synonym for USER_CATALOG
CLU Synonym for USER_CLUSTERS
COLS Synonym for USER_TAB_COLUMNS
DICT Synonym for DICTIONARY
DUAL
IND Synonym for USER_INDEXES
OBJ Synonym for USER_OBJECTS
SEQ Synonym for USER_SEQUENCES
SYN Synonym for USER_SYNONYMS
TABS Synonym for USER_TABLES
10 rows selected.
3.结果非常的令人振奋,都是非常熟悉,非常亲切的视图!下面是CAT输出效果
scott@ora10g> desc cat;
Name Null? Type
------------ -------- -------------------------
TABLE_NAME NOT NULL VARCHAR2(30)
TABLE_TYPE VARCHAR2(11)
scott@ora10g> select * from cat;
TABLE_NAME TABLE_TYPE
----------- -----------
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
4.类似的还有TAB视图,他是sys用户下的视图,授权给public的一个同名
scott@ora10g> desc tab;
Name Null? Type
------------ -------- ----------------
TNAME NOT NULL VARCHAR2(30)
TABTYPE VARCHAR2(7)
CLUSTERID NUMBER
scott@ora10g> select * from tab;
TNAME TABTYPE CLUSTERID
------------ ------- ----------
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
5.小结
熟练使用这些“小”视图,可以极大的提高操作数据库的效率。
不过这些“小”数据字典是由局限性的,请兴趣的朋友可以进一步探索一下这些数据库对象的出处。
阅读(618) | 评论(0) | 转发(0) |