1.Oracle數據遷移備份(cmd方式)
-
從Oracle導出數據到本地電腦
C:\Users\bobo>exp scott/tiger@orcl tables=emp,dept rows=y file=d:\emp_dept.dmp log=d:\emp_dept.log
—rows是行,y代表yes
—數據要dmp格式
-
從本地電腦導入數據到Oracle
emp_dept.dmp源數據文件導入到scott用戶
C:\Users\bobo>imp scott/tiger@orcl fromuser=scott touser=scott file=d:\emp_dept.dmp rows=y log=d:\imp_emp_dept.log
—fromuser是從哪個用戶導出
—touser是導入到哪個用戶下
在Oracle客戶端的tables文件夾下就能看到導入的數據表
-
從本地電腦導入.sql數據到Oracle
使用@關鍵字+文件地址
2.Oracle用戶授權
前期準備:
打開cmd窗口,輸入sqlplus scott/tiger@orcl連接Oracle數據庫
或者
在PLSQL Developer客戶端,打開sql編寫窗口,輸入以下命令也可授權。
-
授權/撤銷授權用戶DBA角色
授權:grant dba to scott;
撤銷:revoke dba from scott; -
表空間授權
創建表空間:grant create tablespace to scott;
修改表空間:grant alter tablespace to scott;
刪除表空間:grant drop tablespace to scott;授權完成後,可以在客戶端查看授權信息,也可以直接在客戶端編輯添加權限。
-
用戶授權
創建用戶:grant create user to scott;
修改用戶:grant alter user to scott;
刪除用戶:grant drop user to scott;
3.創建表空間和用戶
一般是先有數據庫,然後創建N個表空間,再創建用戶,用戶可以指定該表空間,該表空間下可以存儲N張表。
-
創建表空間
create tablespace test
datafile ‘D:\oracle\product\10.2.0\oradata\orcl\test.dbf’
size 10m [autoextend on] [next 1M] [maxsize 2G];—datafile數據庫的路徑要真實存在
—.dbf(database file) 數據庫文件
—size 爲初始表空間大小,單位爲K或者M
—autoextend 是否自動擴展,值爲on或off
—next爲文件滿了後擴展大小
—maxsize爲文件最大大小,值爲數值或unlimited(表示不限大小) -
刪除表空間
drop tablespace 表空間名稱;刪除空表空間,包括創建的數據庫文件
drop tablespace test including contents and datafiles; -
創建用戶
create user test01 identified by test01
default tablespace test
temporary tablespace temp;—identified by:創建用戶名的口令密碼
—默認表空間用test
—臨時空間用temp -
給test01用戶授權連接數據庫
創建完用戶之後,在Users文件夾下能看見test01用戶,但是想登錄test01用戶顯示沒有權限去連接數據庫。
所以需要在system用戶下授權test01用戶連接數據庫。
再次按會話登錄,就能成功登錄上test01用戶。
test01用戶指定了test表空間,創建的表存放在test表空間下。