oracle資料庫的備份(匯出exp)與還原(匯入imp)字尾名為dmp的檔案
1。方式有兩種:利用圖形化介面(連線工具PLSQL Dev)或黑白命令列。
2。這裡先用plsql匯出:
3。以ludy使用者密碼登入,點選Tools-Export Tables這裡匯出的是ludy。dmp檔案其名稱與資料庫使用者名稱相同,其所屬的表空間名也是ludy,表空間檔名是某路徑下的LUDY。DBF。
PLSQL中的exp操作
4。命令列匯入:
5。以system Connect as SYSDBA使用者密碼登入,用命令建立的表空間ludy,使用者ludy(名字最好與原來相同),再對該使用者授權。
6。按win+R輸入cmd開啟命令列視窗輸以下命令:imp ludy/123@orcl file=F:\DBF-dmp\dmp\ludy。dmp fromuser=ludy touser=ludy 回車匯入成功。
7。用建立的使用者和密碼登入,ludy,密碼。在tables中Quary date。
8。若第6步匯入錯誤,提示只有DBA才能匯入由其他DBA匯出的檔案。
解決:grant dba to ludy;
再不行就 alter user ludy default role dba;
附相關命令:
在system as SYSDBA使用者下登入plsql
——建立表空間
create tablespace icity datafile ‘F:\LinRanWork\icity。dbf’ size 10m autoextend on;
——查看錶空間
select * from dba_data_files;
——刪除表空間
drop tablespace icity including contents and datafiles cascade constraint;
——刪除使用者
drop user hy12345 cascade;
——檢視使用者
select * from all_users;
——建立使用者及指定表空間,並授權
create user hy12345 identified by 123 default tablespace icity quota 50m on users;
grant all privileges to hy12345;
——查看錶空間的使用情況
SELECT a。tablespace_name “表空間名稱”,
total / (1024 * 1024) “表空間大小(M)”,
free / (1024 * 1024) “表空間剩餘大小(M)”,
(total - free) / (1024 * 1024 ) “表空間使用大小(M)”,
total / (1024 * 1024 * 1024) “表空間大小(G)”,
free / (1024 * 1024 * 1024) “表空間剩餘大小(G)”,
(total - free) / (1024 * 1024 * 1024) “表空間使用大小(G)”,
round((total - free) / total, 4) * 100 “使用率 %”
FROM (SELECT tablespace_name, SUM(bytes) free
FROM dba_free_space
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_data_files
GROUP BY tablespace_name) b
WHERE a。tablespace_name = b。tablespace_name;