數據庫管理員(DBA)的主要工作
啟動和關閉數據庫
一) 啟動數據庫
$ svrmgrl
SVRMGR> connect internal (實例啟動)
SVRMGR> startup
二) 關閉數據庫
$ svrmgrl
SVRMGR> connect internal
SVRMGR> shutdown [immediate/abort]
immediate:正在訪問數據庫的會話被完全終止、資源有序釋放後才關閉 數據庫。
abort: 會話立即中止,數據庫立即關閉。
備份與恢復
一) 邏輯備份與恢復(即卸庫與裝庫)
1. 卸庫:export
不帶參數:
$ cd $Oracle_HOME/bin
$ exp
Username: cwadmin
PassWord:
Connected to: Oracle8 Enterprise Edition Release 8.0.4.0.0 - Production
PL/SQL Release 8.0.4.0.0 - Production
Enter array fetch buffer size: 4096 >
Export file: expdat.dmp > pzexdat.dmp
(1) E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 1
Export grants (yes/no): yes > y
Export table data (yes/no): yes > y
Compress extents (yes/no): yes >y
export 工作開始自動進行最終出現:
Export terminated successfully without warnings.
帶參數,可選參數如下(可用exp help=y 得到):
Keyword Description (Default) KeyWord Description (Default)
---------------------------------------------------------------------------------------------------
USERID username/passWord FULL export entire file (N)
BUFFER size of data buffer OWNER list of owner usernames
FILE output file (EXPDAT.DMP) TABLES list of table names
COMPRESS import into one extent (Y) RECORDLENGTH length of IO record
GRANTS export grants (Y) INCTYPE incremental export type
INDEXES export indexes (Y) RECORD track incr. export (Y)
ROWS export data rows (Y) PARFILE parameter filename
CONSTRAINTS export constraints (Y) CONSISTENT cross-table consistency
LOG log file of screen output STATISTICS analyze objects (ESTIMATE)
DIRECT direct path (N)
FEEDBACK display progress every x rows (0)
POINT_IN_TIME_RECOVER Tablespace Point-in-time Recovery (N)
RECOVERY_TABLESPACES List of tablespace names to recover
VOLSIZE number of bytes to write to each tape volume
例:$exp userid=cwadmin/cwadmin tables=’(sys_cwxx,sys_menu)’ file=pzexport.dmp
2. 裝庫:
不帶參數
$ cd $Oracle_HOME/bin
$ imp
Username: cwadmin
PassWord:
Connected to: Oracle8 Enterprise Edition Release 8.0.4.0.0 - Production
PL/SQL Release 8.0.4.0.0 - Production
Import file: expdat.dmp > pzexdat.dmp
Enter insert buffer size (minimum is 4096) 30720> 10240
Export file created by EXPORT:V08.00.04 via conventional path
List contents of import file only (yes/no): no >
Ignore create error due to object existence (yes/no): no > y
Import grants (yes/no):yes > y
Import table data (yes/no):yes >y
Import entire export file (yes/no):no >y
import 工作開始自動進行最終出現:
Import terminated successfully with warnings.
帶參數,可選參數如下(可用imp help=y 得到):
Keyword Description (Default) KeyWord Description (Default)
---------------------------------------------------------------------------------------------------
USERID username/passWord FULL import entire file (N)
BUFFER size of data buffer FROMUSER list of owner usernames