oracle數據庫常用命令的整理

 導出表

導出自己的表:
exp  scott/tiger tables=(emp) file=d:\emp.dmp

導出其它方案的表
exp  system/system tables=(scott.emp) file=d:\emp2.dmp

導出表結構
exp  scott/tiger tables=(emp) file=d:\emp.dmp rows=n


使用直接導出方式
exp  scott/tiger tables=(emp) file=d:\emp.dmp direct=y

導出多個方案
exp  system/system owner=(system,scott) file=d:\system.dmp

導出數據庫
exp system/system full=y inctype=complete file=d:\x.dmp

查詢顯示用戶所有的系統權限
select * from dba_sys_privs;

查詢顯示用戶具有的對象權限
select * from dba_tab_privs;

查詢顯示用戶具有的列權限
select * from dba_col_privs;

查詢顯示用戶所具有的角色
select * from dba_role_privs;

查詢oracle中所有的系統權限,一般是dba
select * from system_privilege_map order by name;

查詢oracle中所有的角色,一般是dba
select * from dba_roles;

查詢oracle中所有的對象權限,一般是dba
select distinct privilege from dba_tab_privs;

查詢數據庫的表空間
select tablespace_name from dba_tablespaces;

查看某個角色包括哪些系統權限
select * from dba_sys_privs where grantee='角色名';
或者select * from role_sys_privs where role='角色名';

查看某個角色包括的對象權限
select * from dba_tab_privs where grantee='角色名';

查看某個用戶具有什麼樣的角色
select * from dba_role_privs where grantee='用戶名';

顯示當前用戶可以訪問的所有數據字典視圖
select * from dict where comments like '%grant%'

顯示當前數據庫的全稱
select * from global_name;

EXP-00091 正在導出有問題的統計信息 問題的解決
exp 命令後加上statistics=none

建立表空間
create tablespace 表空間名字 datafile 'd:\glorin.dbf' size 20m uniform size 128k

使表空間脫機
alter tablespace 表空間名 offline;

使表空間聯機
alter tablespace 表空間名 online;

使表空間只讀
alter tablespace 表空間名 read only;

知道表空間名,查看該表空間名包括的所有表
select * from all_tables where tablespace_name='表空間名';

知道表名,查看該表屬於哪個表空間
select tablespace_name,table_name from user_tables where table_name='emp';

刪除表空間
drop tablespace '表空間'including contents and datafiles;

擴展表空間
1)增加數據文件
alter tablespace 表空間名 add datafile='d:\test\sp01.dbf' size 20m

2)增減數據文件的大小
alter database datafile 'd:\test\sp01.dbf' resize 20m;

3)設置文件的自動增長
alter database datafile 'd:\test\sp01.dbf' autoextend on next 10m maxsize 500m;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章