-- 查看表空间文件地址 SELECT FILE_NAME, BLOCKS, TABLESPACE_NAME FROM DBA_DATA_FILES;
-- 检查表空间文件大小,输入表空间名字 -- 结果为 MB Select (sum(bytes)/1024/1024) Space_allocated from dba_data_files where tablespace_name=upper('&tname');
Schema 与用户
1 2 3 4 5 6 7 8
-- Schema 与用户的区别 -- A schema is a collection of database objects (used by a user.). -- Schema objects are the logical structures that directly refer to the database’s data. -- A user is a name defined in the database that can connect to and access objects. -- Schemas and users help database administrators manage database security. -- 一个用户有一个缺省的schema,其schema名就等于用户名,当然一个用户还可以使用其他的schema。 -- 查用户信息,包括 schema SELECT*FROM sys.dba_users;
-- user index select INDEX_NAME, TABLE_OWNER, TABLE_NAME, UNIQUENESS from USER_INDEXES
-- all index select INDEX_NAME, TABLE_OWNER, TABLE_NAME, UNIQUENESS from ALL_INDEXES
-- all index filter by table name select INDEX_NAME, TABLE_OWNER, TABLE_NAME, UNIQUENESS from ALL_INDEXES where table_owner like'%DC%'
-- all index group by table owner select table_owner, COUNT(TABLE_OWNER) from ALL_INDEXES groupby table_owner;
表与视图
有哪些表和视图
1 2 3 4 5 6 7 8 9 10 11 12
-- list all user's table select table_name from all_tables orderby table_name
-- list all views select view_name from all_views where view_name like'GRA%'orderby view_name;
-- check table length select table_name, num_rows from all_tables;
-- create table from another view or table createtable prs7.t_gra_stores_mapping_dc as (select*from prs4.GRA_STORE_MAPPING_INFO_DC);
检查表占用空间
1 2 3 4 5
select segment_name, sum(bytes)/1024/1024/1024 GB from user_segments where segment_type='TABLE' and segment_name=upper('&TABLE_NAME') group by segment_name;
查看执行计划
1 2 3 4
explain plan for select a, b, c from table_name select*fromTABLE(dbms_xplan.display);