【Oracle】常用字典表

【查看当前用户的缺省表空间】

SQL:select username,default_tablespace from user_users

运行:

luna@ORCL>select username,default_tablespace from user_users;

USERNAME                       DEFAULT_TABLESPACE
------------------------------ ------------------------------
LUNA                           USERS

 

【查看当前用户的角色】

SQL:select * from user_role_privs

运行:

luna@ORCL>select * from user_role_privs;

USERNAME                       GRANTED_ROLE                   ADM DEF OS_
------------------------------ ------------------------------ --- --- ---
LUNA                           DBA                            NO  YES NO

已选择 1 行。

 

【查看用户下所有的表】

SQL:select table_name,tablespace_name from user_tables

运行:

luna@ORCL>select table_name,tablespace_name from user_tables;

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
TEST01                         USERS
TEST02                         USERS
TEST04                         USERS
TEST06                         USERS
TEST07                         USERS
TEST05                         USERS
DEPT                           USERS
EMP76                          USERS
EMP625_FROM                    USERS
EMP722                         USERS
DIC722                         USERS
EMP826                         USERS
SAL0826                        USERS
TEST03                         USERS
EMP625_TO                      USERS

使用 select * from user_catalog或select * from cat也是一样的效果(cat是user_catalog的别名)

luna@ORCL>select * from cat;

TABLE_NAME           TABLE_TYPE
-------------------- -----------
DEPT                 TABLE
DIC722               TABLE
EMP625_FROM          TABLE
EMP625_TO            TABLE
EMP722               TABLE
EMP76                TABLE
EMP826               TABLE
SAL0826              TABLE
TEST01               TABLE
TEST02               TABLE
TEST03               TABLE
TEST04               TABLE
TEST05               TABLE
TEST06               TABLE
TEST07               TABLE

已选择15行。

luna@ORCL>select * from user_catalog;

TABLE_NAME           TABLE_TYPE
-------------------- -----------
DEPT                 TABLE
DIC722               TABLE
EMP625_FROM          TABLE
EMP625_TO            TABLE
EMP722               TABLE
EMP76                TABLE
EMP826               TABLE
SAL0826              TABLE
TEST01               TABLE
TEST02               TABLE
TEST03               TABLE
TEST04               TABLE
TEST05               TABLE
TEST06               TABLE
TEST07               TABLE

 

【查看用户拥有的名称包括emp的表】

SQL:select table_name,tablespace_name from user_tables where instr(table_name,'EMP')>0;

运行:

luna@ORCL>select table_name,tablespace_name from user_tables where instr(table_name,'EMP')>0;

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
EMP625_TO                      USERS
EMP722                         USERS
EMP826                         USERS
EMP625_FROM                    USERS
EMP76                          USERS

 

【查某表(EMP625_FROM为表名)占用的空间】

SQL:select sum(bytes)/(1024*1024) as m_bytes  from user_segments where segment_name=upper('EMP625_FROM')

运行:

luna@ORCL>select sum(bytes)/(1024*1024) as m_bytes  from user_segments where segment_name=upper('EMP625_FROM');

   M_BYTES
----------
        72

 

【查看索引及所在的表】

SQL:select index_name,index_type,table_name from user_indexes order by table_name

 运行:

luna@ORCL>select index_name,index_type,table_name from user_indexes order by table_name;

INDEX_NAME           INDEX_TYPE           TABLE_NAME
-------------------- -------------------- --------------------
SYS_C0011417         NORMAL               DEPT
SYS_C0011561         NORMAL               DIC722
SYS_C0011558         NORMAL               EMP625_FROM
SYS_C0011559         NORMAL               EMP625_TO
SYS_C0011560         NORMAL               EMP722
SYS_C0011557         NORMAL               EMP76
SYS_C0011205         NORMAL               TEST02
SYS_IL0000074896C000 LOB                  TEST03
02$$
SYS_C0011206         NORMAL               TEST03
SYS_C0011248         NORMAL               TEST04
SYS_C0011251         NORMAL               TEST05

 【查看数据库的版本】

 SQL:Select version FROM Product_component_version Where SUBSTR(PRODUCT,1,6)='Oracle'

运行:

luna@ORCL>Select version FROM Product_component_version Where SUBSTR(PRODUCT,1,6)='Oracle';

VERSION
--------------------------------------------------------------------------------
11.2.0.1.0

 

未完待续

posted @ 2022-10-05 13:00  逆火狂飙  阅读(212)  评论(0编辑  收藏  举报
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东