//创建一个控制文件命令到跟踪文件
alterdatabasebackupcontrolfiletotrace;
//增加一个新的日志文件组的语句
connectinternalassysdba
alterdatabase
addlogfilegroup4
(’/db01/oracle/CC1/log_1c.dbf’,
’/db02/oracle/CC1/log_2c.dbf’)size5M;
alterdatabase
addlogfilemember’/db03/oracle/CC1/log_3c.dbf’
togroup4;
//在ServerManager上MOUNT并打开一个数据库:
connectinternalassysdba
startupmountORA1exclusive;
alterdatabaseopen;
//生成数据字典
@catalog
@catproc
//在init.ora中备份数据库的位置
log_archive_dest_1=’/db00/arch’
log_archive_dest_state_1=enable
log_archive_dest_2="service=stby.worldmandatoryreopen=60"
log_archive_dest_state_2=enable
//对用户的表空间的指定和管理相关的语句
createuserUSERNAMEidentifiedbyPASSWORD
defaulttablespaceTABLESPACE_NAME;
alteruserUSERNAMEdefaulttablespaceTABLESPACE_NAME;
alteruserSYSTEMquota0onSYSTEM;
alteruserSYSTEMquota50MonTOOLS;
createuserUSERNAMEidentifiedbyPASSWORD
defaulttablespaceDATA
temporarytablespaceTEMP;
alteruserUSERNAMEtemporarytablespaceTEMP;
//重新指定一个数据文件的大小:
alterdatabase
datafile’/db05/oracle/CC1/data01.dbf’resize200M;
//创建一个自动扩展的数据文件:
createtablespaceDATA
datafile’/db05/oracle/CC1/data01.dbf’size200M
autoextendON
next10M
maxsize250M;
//在表空间上增加一个自动扩展的数据文件:
altertablespaceDATA
adddatafile’/db05/oracle/CC1/data02.dbf’
size50M
autoextendON
maxsize300M;
//修改参数:
alterdatabase
datafile’/db05/oracle/CC1/data01.dbf’
autoextendON
maxsize300M;
//在数据文件移动期间重新命名:
alterdatabaserenamefile
’/db01/oracle/CC1/data01.dbf’to
’/db02/oracle/CC1/data01.dbf’;
altertablespaceDATArenamedatafile
’/db01/oracle/CC1/data01.dbf’to
’/db02/oracle/CC1/data01.dbf’;
alterdatabaserenamefile
’/db05/oracle/CC1/redo01CC1.dbf’to
’/db02/oracle/CC1/redo01CC1.dbf’;
alterdatabasedatafile’/db05/oracle/CC1/data01.dbf’
resize80M;
//创建和使用角色:
createroleAPPLICATION_USER;
grantCREATESESSIONtoAPPLICATION_USER;
grantAPPLICATION_USERtousername;
//回滚段的管理
createrollbacksegmentSEGMENT_NAME
tablespaceRBS;
alterrollbacksegmentSEGMENT_NAMEoffline;
droprollbacksegmentSEGMENT_NAME;
alterrollbacksegmentSEGMENT_NAMEonline;
//回滚段上指定事务
commit;
settransactionuserollbacksegmentROLL_BATCH;
insertintoTABLE_NAME
select*fromDATA_LOAD_TABLE;
commit;
//查询回滚段的大小和优化参数
select*fromDBA_SEGMENTS
whereSegment_Type=’ROLLBACK’;
selectN.Name,/*rollbacksegmentname*/
S.OptSize/*rollbacksegmentOPTIMALsize*/
fromV$ROLLNAMEN,V$ROLLSTATS
whereN.USN=S.USN;
//回收回滚段
alterrollbacksegmentR1shrinkto15M;
alterrollbacksegmentR1shrink;
//例子
settransactionuserollbacksegmentSEGMENT_NAME
altertablespaceRBS
defaultstorage
(initial125Knext125Kminextents18maxextents249)
createrollbacksegmentR4tablespaceRBS
storage(optimal2250K);
alterrollbacksegmentR4online;
selectSessions_HighwaterfromV$LICENSE;
grantselectonEMPLOYEEtoPUBLIC;
//用户和角色
createroleACCOUNT_CREATOR;
grantCREATESESSION,CREATEUSER,ALTERUSER
toACCOUNT_CREATOR;
alteruserTHUMPERdefaultroleNONE;
alteruserTHUMPERdefaultroleCONNECT;
alteruserTHUMPERdefaultroleallexceptACCOUNT_CREATOR;
alterprofileDEFAULT
limitidle_time60;
createprofileLIMITED_PROFILElimit
FAILED_LOGIN_ATTEMPTS5;
createuserJANEidentifiedbyEYRE
profileLIMITED_PROFILE;
grantCREATESESSIONtoJANE;
alteruserJANEaccountunlock;
alteruserJANEaccountlock;
alterprofileLIMITED_PROFILElimit
PASSWORD_LIFE_TIME30;
alteruserjanepasswordexpire;
//创建操作系统用户
REMCreatingOPS$accounts
createuserOPS$FARMER
identifiedbySOME_PASSWORD
defaulttablespaceUSERS
temporarytablespaceTEMP;
REMUsingidentifiedexternally
createuserOPS$FARMER
identifiedexternally
defaulttablespaceUSERS
temporarytablespaceTEMP;
//执行ORAPWD
ORAPWDFILE=filenamePASSWORD=passwordENTRIES=max_users
createroleAPPLICATION_USER;
grantCREATESESSIONtoAPPLICATION_USER;
createroleDATA_ENTRY_CLERK;
grantselect,insertonTHUMPER.EMPLOYEEtoDATA_ENTRY_CLERK;
grantselect,insertonTHUMPER.TIME_CARDStoDATA_ENTRY_CLERK;
grantselect,insertonTHUMPER.DEPARTMENTtoDATA_ENTRY_CLERK;
grantAPPLICATION_USERtoDATA_ENTRY_CLERK;
grantDATA_ENTRY_CLERKtoMCGREGOR;
grantDATA_ENTRY_CLERKtoBPOTTERwithadminoption;
//设置角色
setroleDATA_ENTRY_CLERK;
setroleNONE;
//回收权利:
revokedeleteonEMPLOYEEfromPETER;
revokeallonEMPLOYEEfromMCGREGOR;
//回收角色:
revokeACCOUNT_CREATORfromHELPDESK;
dropuserUSERNAMEcascade;
grantSELECTonEMPLOYEEtoMCGREGORwithgrantoption;
grantSELECTonTHUMPER.EMPLOYEEtoBPOTTERwithgrantoption;
revokeSELECTonEMPLOYEEfromMCGREGOR;
createuserMCGREGORidentifiedbyVALUES’1A2DD3CCEE354DFA’;
alteruserOPS$FARMERidentifiedbyVALUES’noway’;
//备份与恢复
使用export程序
expsystem/managerfile=expdat.dmpcompress=Yowner=(HR,THUMPER)
expsystem/managerfile=hr.dmpowner=HRindexes=Ycompress=Y
impsystem/managerfile=hr.dmpfull=Ybuffer=64000commit=Y
//备份表
expsystem/managerFILE=expdat.dmpTABLES=(Thumper.SALES)
//备份分区
expsystem/managerFILE=expdat.dmpTABLES=(Thumper.SALES:Part1)
//输入例子
impsystem/managerfile=expdat.dmp
impsystem/managerfile=expdat.dmpbuffer=64000commit=Y
expsystem/managerfile=thumper.datowner=thumpergrants=N
indexes=Ycompress=Yrows=Y
impsystem/managerfile=thumper.datFROMUSER=thumperTOUSER=flower
rows=Yindexes=Y
impsystem/managerfile=expdat.dmpfull=Ycommit=Ybuffer=64000
impsystem/managerfile=expdat.dmpignore=Nrows=Ncommit=Ybuffer=64000
//使用操作系统备份命令
REMTARexamples
tar-cvf/dev/rmt/0hc/db0[1-9]/oracle/CC1
tar-rvf/dev/rmt/0hc/orasw/app/oracle/CC1/pfile/initcc1.ora
tar-rvf/dev/rmt/0hc/db0[1-9]/oracle/CC1/orasw/app/oracle/CC1/pfile/initcc1.ora
//离线备份的shell脚本
ORACLE_SID=cc1;exportORACLE_SID
ORAENV_ASK=NO;exportORAENV_ASK
.oraenv
svrmgrl<<EOF1
connectinternalassysdba
shutdownimmediate;
exit
EOF1
insertbackupcommandslikethe"tar"commandshere
svrmgrl<<EOF2
connectinternalassysdba
startup
EOF2
//在ServerManager上设置为archivelogmode:
connectinternalassysdba
startupmountcc1;
alterdatabasearchivelog;
archivelogstart;
alterdatabaseopen;
//在ServerManager上设置为archivelogmode:
connectinternalassysdba
startupmountcc1;
alterdatabasenoarchivelog;
alterdatabaseopen;
selectName,
Value
fromV$PARAMETER
whereNamelike’log_archive%’;
//联机备份的脚本
#
#SampleHotBackupScriptforaUNIXFileSystemdatabase
#
#Setupenvironmentvariables:
ORACLE_SID=cc1;exportORACLE_SID
ORAENV_ASK=NO;exportORAENV_ASK
.oraenv
svrmgrl<<EOFarch1
connectinternalassysdba
REM
REM备份SYSTEMtablespace
REM
altertablespaceSYSTEMbeginbackup;
!tar-cvf/dev/rmt/0hc/db01/oracle/CC1/sys01.dbf
altertablespaceSYSTEMendbackup;
REM
REMTheSYSTEMtablespacehasnowbeenwrittentoa
REMtarsavesetonthetapedevice/dev/rmt/0hc.The
REMrestofthetarsmustusethe"-rvf"clausetoappend
REMtothatsaveset.
REM
REM备份RBStablespace
REM
altertablespaceRBSbeginbackup;
!tar-rvf/dev/rmt/0hc/db02/oracle/CC1/rbs01.dbf
altertablespaceRBSendbackup;
REM
REM备份DATAtablespace
REMForthepurposesofthisexample,thistablespace
REMwillcontaintwofiles,data01.dbfanddata02.dbf.
REMThe*wildcardwillbeusedinthefilename.
REM
altertablespaceDATAbeginbackup;
!tar-rvf/dev/rmt/0hc/db03/oracle/CC1/data0*.dbf
altertablespaceDATAendbackup;
REM
REM备份INDEXEStablespace
REM
altertablespaceINDEXESbeginbackup;
!tar-rvf/dev/rmt/0hc/db04/oracle/CC1/indexes01.dbf
altertablespaceINDEXESendbackup;
REM
REM备份TEMPtablespace
REM
altertablespaceTEMPbeginbackup;
!tar-rvf/dev/rmt/0hc/db05/oracle/CC1/temp01.dbf
altertablespaceTEMPendbackup;
REM
REMFollowthesamepatterntobackuptherest
REMofthetablespaces.
REM
REM
REMStep2.备份归档日志文件.
archivelogstop
REM
REMExitServerManager,usingtheindicatorsetearlier.
exit
EOFarch1
#
#Recordwhichfilesareinthedestinationdirectory.
#Dothisbysettinganenvironmentvariablethatis
#equaltothedirectorylistingforthedestination
#directory.
#Forthisexample,thelog_archive_destis
#/db01/oracle/arch/CC1.
#
FILES=`ls/db01/oracle/arch/CC1/arch*.dbf`;exportFILES
#
#NowgobackintoServerManagerandrestartthe
#archivingprocess.Setanindicator(calledEOFarch2
#inthisexample).
#
svrmgrl<<EOFarch2
connectinternal
archivelogstart;
exit
EOFarch2
#
#Nowbackupthearchivedredologstothetape
#deviceviathe"tar"command,thendeletethem
#fromthedestinationdeviceviathe"rm"command.
#Youmaychoosetocompresstheminstead.
#
tar-rvf/dev/rmt/0hc$FILES
rm-f$FILES
#
#Step3.备份控制文件到磁盘.
#
svrmgrl<<EOFarch3
connectinternal
alterdatabasebackupcontrolfileto
’db01/oracle/CC1/CC1controlfile.bck’;
exit
EOFarch3
#
#备份控制文件到磁带.
#
tar-rvf/dev/rmt/0hc/db01/oracle/CC1/CC1controlfile.bck
#
#Endofhotbackupscript.
//自动生成开始备份的脚本
setpagesize0feedbackoff
select
’altertablespace’||Tablespace_Name||’beginbackup;’
fromDBA_TABLESPACES
whereStatus<>’INVALID’
spoolalter_begin.sql
/
spooloff
//自动生成备份结束的脚本
setpagesize0feedbackoff
select
’altertablespace’||Tablespace_Name||’endbackup;’
fromDBA_TABLESPACES
whereStatus<>’INVALID’
spoolalter_end.sql
/
spooloff
//备份归档日志文件的脚本.
REMSeetextforalternatives.
#Step1:Stopthearchivingprocess.Thiswillkeep
#additionalarchivedredologfilesfrombeingwritten
#tothedestinationdirectoryduringthisprocess.
#
svrmgrl<<EOFarch1
connectinternalassysdba
archivelogstop;
REM
REMExitServerManagerusingtheindicatorsetearlier.
exit
EOFarch1
#
#Step2:Recordwhichfilesareinthedestination
#directory.
#Dothisbysettinganenvironmentvariablethatis
#equaltothedirectorylistingforthedestination
#directory.
#Forthisexample,thelog_archive_destis
#/db01/oracle/arch/CC1.
#
FILES=`ls/db01/oracle/arch/CC1/arch*.dbf`;exportFILES
#
#Step3:GobackintoServerManagerandrestartthe
#archivingprocess.Setanindicator(calledEOFarch2
#inthisexample).
#
svrmgrl<<EOFarch2
connectinternalassysdba
archivelogstart;
exit
EOFarch2
#
#Step4.Backupthearchivedredologstothetape
#deviceviathe"tar"command,thendeletethem
#fromthedestinationdeviceviathe"rm"command.
#
tar-rvf/dev/rmt/0hc$FILES
#
#Step5.Deletethosefilesfromthedestinationdirectory.
#
rm-f$FILES
#
#Endofarchivedredologfilebackupscript.
REM磁盘到磁盘的备份
REM
REMBackuptheRBStablespace-toanotherdisk(UNIX)
REM
altertablespaceRBSbeginbackup;
!cp/db02/oracle/CC1/rbs01.dbf/db10/oracle/CC1/backups
altertablespaceRBSendbackup;
REM
REM移动归档日志文件的shell脚本
#
#Procedureformovingarchivedredologstoanotherdevice
#
svrmgrl<<EOFarch2
connectinternalassysdba
archivelogstop;
!mv/db01/oracle/arch/CC1/db10/oracle/arch/CC1
archivelogstart;
exit
EOFarch2
#
#endofarchivedredologdirectorymove.
//生成创建控制文件命令
alterdatabasebackupcontrolfiletotrace;
//时间点恢复的例子
connectinternalassysdba
startupmountinstance_name;
recoverdatabaseuntiltime’1999-08-07:14:40:00’;
//创建恢复目录
rmanrcvcatrman/rman@<database_service_name>
//在(UNIX)下创建恢复目录
RMAN>createcatalogtablespacercvcat;
//在(NT)下创建恢复目录
RMAN>createcatalogtablespace"RCVCAT";
//连接描述符范例
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=HQ)
(PORT=1521))
(CONNECTDATA=
(SID=loc)))
//listener.ora的条目entry
// listener.ora 的条目entry
LISTENER =
(ADDRESS_LIST =
(ADDRESS=
(PROTOCOL=IPC)
(KEY= loc.world)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = loc)
(ORACLE_HOME = /orasw/app/oracle/product/8.1.5.1)
)
)
// tnsnames.ora 的条目
LOC=
(DESCRIPTION=
(ADDRESS =
(PROTOCOL = TCP)
(HOST = HQ)
(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = loc)
(INSTANCE_NAME = loc)
)
)
//连接参数的设置(sql*net)
LOC =(DESCRIPTION=
(ADDRESS=
(COMMUNITY=TCP.HQ.COMPANY)
(PROTOCOL=TCP)
(HOST=HQ)
(PORT=1521))
(CONNECT DATA=
(SID=loc)))
//参数文件配置范例
// tnsnames.ora
HQ =(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=HQ)
(PORT=1521))
(CONNECT DATA=
(SID=loc)))
// listener.ora
LISTENER =
(ADDRESS_LIST =
(ADDRESS=
(PROTOCOL=IPC)
(KEY= loc)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = loc)
(ORACLE_HOME = /orasw/app/oracle/product/8.1.5.1)
)
)
// Oracle8I tnsnames.ora
LOC=
(DESCRIPTION=
(ADDRESS =
(PROTOCOL = TCP)
(HOST = HQ)
(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = loc)
(INSTANCE_NAME = loc)
)
)
//使用 COPY 实现数据库之间的复制
copy from
remote_username/remote_password@service_name
to
username/password@service_name
[append|create|insert|replace]
TABLE_NAME
using subquery;
REM COPY example
set copycommit 1
set arraysize 1000
copy from HR/PUFFINSTUFF@loc -
create EMPLOYEE -
using -
select * from EMPLOYEE
//监视器的管理
lsnrctl start
lsnrctl start my_lsnr
lsnrctl status
lsnrctl status hq
检查监视器的进程
ps -ef | grep tnslsnr
//在 lsnrctl 内停止监视器
set password lsnr_password
stop
//在lsnrctl 内列出所有的服务
set password lsnr_password
services
//启动或停止一个NT的listener
net start Oracle<version_name>TNSListener
net stop Oracle<version_name>TNSListener
// tnsnames.ora 文件的内容
fld1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)
(HOST = server1.fld.com)(PORT = 1521))
)
(CONNECT_DATA =
(SID = fld1)
)
)
//操作系统网络的管理
telnet host_name
ping host_name
/etc/hosts 文件
130.110.238.109 nmhost
130.110.238.101 txhost
130.110.238.102 azhost arizona
//oratab 表项
loc:/orasw/app/oracle/product/8.1.5.1:Y
cc1:/orasw/app/oracle/product/8.1.5.1:N
old:/orasw/app/oracle/product/8.1.5.0:Y
//创建一个控制文件命令到跟踪文件
alterdatabasebackupcontrolfiletotrace;
//增加一个新的日志文件组的语句
connectinternalassysdba
alterdatabase
addlogfilegroup4
(’/db01/oracle/CC1/log_1c.dbf’,
’/db02/oracle/CC1/log_2c.dbf’)size5M;
alterdatabase
addlogfilemember’/db03/oracle/CC1/log_3c.dbf’
togroup4;
//在ServerManager上MOUNT并打开一个数据库:
connectinternalassysdba
startupmountORA1exclusive;
alterdatabaseopen;
//生成数据字典
@catalog
@catproc
//在init.ora中备份数据库的位置
log_archive_dest_1=’/db00/arch’
log_archive_dest_state_1=enable
log_archive_dest_2="service=stby.worldmandatoryreopen=60"
log_archive_dest_state_2=enable
//对用户的表空间的指定和管理相关的语句
createuserUSERNAMEidentifiedbyPASSWORD
defaulttablespaceTABLESPACE_NAME;
alteruserUSERNAMEdefaulttablespaceTABLESPACE_NAME;
alteruserSYSTEMquota0onSYSTEM;
alteruserSYSTEMquota50MonTOOLS;
createuserUSERNAMEidentifiedbyPASSWORD
defaulttablespaceDATA
temporarytablespaceTEMP;
alteruserUSERNAMEtemporarytablespaceTEMP;
//重新指定一个数据文件的大小:
alterdatabase
datafile’/db05/oracle/CC1/data01.dbf’resize200M;
//创建一个自动扩展的数据文件:
createtablespaceDATA
datafile’/db05/oracle/CC1/data01.dbf’size200M
autoextendON
next10M
maxsize250M;
//在表空间上增加一个自动扩展的数据文件:
altertablespaceDATA
adddatafile’/db05/oracle/CC1/data02.dbf’
size50M
autoextendON
maxsize300M;
//修改参数:
alterdatabase
datafile’/db05/oracle/CC1/data01.dbf’
autoextendON
maxsize300M;
//在数据文件移动期间重新命名:
alterdatabaserenamefile
’/db01/oracle/CC1/data01.dbf’to
’/db02/oracle/CC1/data01.dbf’;
altertablespaceDATArenamedatafile
’/db01/oracle/CC1/data01.dbf’to
’/db02/oracle/CC1/data01.dbf’;
alterdatabaserenamefile
’/db05/oracle/CC1/redo01CC1.dbf’to
’/db02/oracle/CC1/redo01CC1.dbf’;
alterdatabasedatafile’/db05/oracle/CC1/data01.dbf’
resize80M;
//创建和使用角色:
createroleAPPLICATION_USER;
grantCREATESESSIONtoAPPLICATION_USER;
grantAPPLICATION_USERtousername;
//回滚段的管理
createrollbacksegmentSEGMENT_NAME
tablespaceRBS;
alterrollbacksegmentSEGMENT_NAMEoffline;
droprollbacksegmentSEGMENT_NAME;
alterrollbacksegmentSEGMENT_NAMEonline;
//回滚段上指定事务
commit;
settransactionuserollbacksegmentROLL_BATCH;
insertintoTABLE_NAME
select*fromDATA_LOAD_TABLE;
commit;
//查询回滚段的大小和优化参数
select*fromDBA_SEGMENTS
whereSegment_Type=’ROLLBACK’;
selectN.Name,/*rollbacksegmentname*/
S.OptSize/*rollbacksegmentOPTIMALsize*/
fromV$ROLLNAMEN,V$ROLLSTATS
whereN.USN=S.USN;
//回收回滚段
alterrollbacksegmentR1shrinkto15M;
alterrollbacksegmentR1shrink;
//例子
settransactionuserollbacksegmentSEGMENT_NAME
altertablespaceRBS
defaultstorage
(initial125Knext125Kminextents18maxextents249)
createrollbacksegmentR4tablespaceRBS
storage(optimal2250K);
alterrollbacksegmentR4online;
selectSessions_HighwaterfromV$LICENSE;
grantselectonEMPLOYEEtoPUBLIC;
//用户和角色
createroleACCOUNT_CREATOR;
grantCREATESESSION,CREATEUSER,ALTERUSER
toACCOUNT_CREATOR;
alteruserTHUMPERdefaultroleNONE;
alteruserTHUMPERdefaultroleCONNECT;
alteruserTHUMPERdefaultroleallexceptACCOUNT_CREATOR;
alterprofileDEFAULT
limitidle_time60;
createprofileLIMITED_PROFILElimit
FAILED_LOGIN_ATTEMPTS5;
createuserJANEidentifiedbyEYRE
profileLIMITED_PROFILE;
grantCREATESESSIONtoJANE;
alteruserJANEaccountunlock;
alteruserJANEaccountlock;
alterprofileLIMITED_PROFILElimit
PASSWORD_LIFE_TIME30;
alteruserjanepasswordexpire;
//创建操作系统用户
REMCreatingOPS$accounts
createuserOPS$FARMER
identifiedbySOME_PASSWORD
defaulttablespaceUSERS
temporarytablespaceTEMP;
REMUsingidentifiedexternally
createuserOPS$FARMER
identifiedexternally
defaulttablespaceUSERS
temporarytablespaceTEMP;
//执行ORAPWD
ORAPWDFILE=filenamePASSWORD=passwordENTRIES=max_users
createroleAPPLICATION_USER;
grantCREATESESSIONtoAPPLICATION_USER;
createroleDATA_ENTRY_CLERK;
grantselect,insertonTHUMPER.EMPLOYEEtoDATA_ENTRY_CLERK;
grantselect,insertonTHUMPER.TIME_CARDStoDATA_ENTRY_CLERK;
grantselect,insertonTHUMPER.DEPARTMENTtoDATA_ENTRY_CLERK;
grantAPPLICATION_USERtoDATA_ENTRY_CLERK;
grantDATA_ENTRY_CLERKtoMCGREGOR;
grantDATA_ENTRY_CLERKtoBPOTTERwithadminoption;
//设置角色
setroleDATA_ENTRY_CLERK;
setroleNONE;
//回收权利:
revokedeleteonEMPLOYEEfromPETER;
revokeallonEMPLOYEEfromMCGREGOR;
//回收角色:
revokeACCOUNT_CREATORfromHELPDESK;
dropuserUSERNAMEcascade;
grantSELECTonEMPLOYEEtoMCGREGORwithgrantoption;
grantSELECTonTHUMPER.EMPLOYEEtoBPOTTERwithgrantoption;
revokeSELECTonEMPLOYEEfromMCGREGOR;
createuserMCGREGORidentifiedbyVALUES’1A2DD3CCEE354DFA’;
alteruserOPS$FARMERidentifiedbyVALUES’noway’;
//备份与恢复
使用export程序
expsystem/managerfile=expdat.dmpcompress=Yowner=(HR,THUMPER)
expsystem/managerfile=hr.dmpowner=HRindexes=Ycompress=Y
impsystem/managerfile=hr.dmpfull=Ybuffer=64000commit=Y
//备份表
expsystem/managerFILE=expdat.dmpTABLES=(Thumper.SALES)
//备份分区
expsystem/managerFILE=expdat.dmpTABLES=(Thumper.SALES:Part1)
//输入例子
impsystem/managerfile=expdat.dmp
impsystem/managerfile=expdat.dmpbuffer=64000commit=Y
expsystem/managerfile=thumper.datowner=thumpergrants=N
indexes=Ycompress=Yrows=Y
impsystem/managerfile=thumper.datFROMUSER=thumperTOUSER=flower
rows=Yindexes=Y
impsystem/managerfile=expdat.dmpfull=Ycommit=Ybuffer=64000
impsystem/managerfile=expdat.dmpignore=Nrows=Ncommit=Ybuffer=64000
//使用操作系统备份命令
REMTARexamples
tar-cvf/dev/rmt/0hc/db0[1-9]/oracle/CC1
tar-rvf/dev/rmt/0hc/orasw/app/oracle/CC1/pfile/initcc1.ora
tar-rvf/dev/rmt/0hc/db0[1-9]/oracle/CC1/orasw/app/oracle/CC1/pfile/initcc1.ora
//离线备份的shell脚本
ORACLE_SID=cc1;exportORACLE_SID
ORAENV_ASK=NO;exportORAENV_ASK
.oraenv
svrmgrl<<EOF1
connectinternalassysdba
shutdownimmediate;
exit
EOF1
insertbackupcommandslikethe"tar"commandshere
svrmgrl<<EOF2
connectinternalassysdba
startup
EOF2
//在ServerManager上设置为archivelogmode:
connectinternalassysdba
startupmountcc1;
alterdatabasearchivelog;
archivelogstart;
alterdatabaseopen;
//在ServerManager上设置为archivelogmode:
connectinternalassysdba
startupmountcc1;
alterdatabasenoarchivelog;
alterdatabaseopen;
selectName,
Value
fromV$PARAMETER
whereNamelike’log_archive%’;
//联机备份的脚本
#
#SampleHotBackupScriptforaUNIXFileSystemdatabase
#
#Setupenvironmentvariables:
ORACLE_SID=cc1;exportORACLE_SID
ORAENV_ASK=NO;exportORAENV_ASK
.oraenv
svrmgrl<<EOFarch1
connectinternalassysdba
REM
REM备份SYSTEMtablespace
REM
altertablespaceSYSTEMbeginbackup;
!tar-cvf/dev/rmt/0hc/db01/oracle/CC1/sys01.dbf
altertablespaceSYSTEMendbackup;
REM
REMTheSYSTEMtablespacehasnowbeenwrittentoa
REMtarsavesetonthetapedevice/dev/rmt/0hc.The
REMrestofthetarsmustusethe"-rvf"clausetoappend
REMtothatsaveset.
REM
REM备份RBStablespace
REM
altertablespaceRBSbeginbackup;
!tar-rvf/dev/rmt/0hc/db02/oracle/CC1/rbs01.dbf
altertablespaceRBSendbackup;
REM
REM备份DATAtablespace
REMForthepurposesofthisexample,thistablespace
REMwillcontaintwofiles,data01.dbfanddata02.dbf.
REMThe*wildcardwillbeusedinthefilename.
REM
altertablespaceDATAbeginbackup;
!tar-rvf/dev/rmt/0hc/db03/oracle/CC1/data0*.dbf
altertablespaceDATAendbackup;
REM
REM备份INDEXEStablespace
REM
altertablespaceINDEXESbeginbackup;
!tar-rvf/dev/rmt/0hc/db04/oracle/CC1/indexes01.dbf
altertablespaceINDEXESendbackup;
REM
REM备份TEMPtablespace
REM
altertablespaceTEMPbeginbackup;
!tar-rvf/dev/rmt/0hc/db05/oracle/CC1/temp01.dbf
altertablespaceTEMPendbackup;
REM
REMFollowthesamepatterntobackuptherest
REMofthetablespaces.
REM
REM
REMStep2.备份归档日志文件.
archivelogstop
REM
REMExitServerManager,usingtheindicatorsetearlier.
exit
EOFarch1
#
#Recordwhichfilesareinthedestinationdirectory.
#Dothisbysettinganenvironmentvariablethatis
#equaltothedirectorylistingforthedestination
#directory.
#Forthisexample,thelog_archive_destis
#/db01/oracle/arch/CC1.
#
FILES=`ls/db01/oracle/arch/CC1/arch*.dbf`;exportFILES
#
#NowgobackintoServerManagerandrestartthe
#archivingprocess.Setanindicator(calledEOFarch2
#inthisexample).
#
svrmgrl<<EOFarch2
connectinternal
archivelogstart;
exit
EOFarch2
#
#Nowbackupthearchivedredologstothetape
#deviceviathe"tar"command,thendeletethem
#fromthedestinationdeviceviathe"rm"command.
#Youmaychoosetocompresstheminstead.
#
tar-rvf/dev/rmt/0hc$FILES
rm-f$FILES
#
#Step3.备份控制文件到磁盘.
#
svrmgrl<<EOFarch3
connectinternal
alterdatabasebackupcontrolfileto
’db01/oracle/CC1/CC1controlfile.bck’;
exit
EOFarch3
#
#备份控制文件到磁带.
#
tar-rvf/dev/rmt/0hc/db01/oracle/CC1/CC1controlfile.bck
#
#Endofhotbackupscript.
//自动生成开始备份的脚本
setpagesize0feedbackoff
select
’altertablespace’||Tablespace_Name||’beginbackup;’
fromDBA_TABLESPACES
whereStatus<>’INVALID’
spoolalter_begin.sql
/
spooloff
//自动生成备份结束的脚本
setpagesize0feedbackoff
select
’altertablespace’||Tablespace_Name||’endbackup;’
fromDBA_TABLESPACES
whereStatus<>’INVALID’
spoolalter_end.sql
/
spooloff
//备份归档日志文件的脚本.
REMSeetextforalternatives.
#Step1:Stopthearchivingprocess.Thiswillkeep
#additionalarchivedredologfilesfrombeingwritten
#tothedestinationdirectoryduringthisprocess.
#
svrmgrl<<EOFarch1
connectinternalassysdba
archivelogstop;
REM
REMExitServerManagerusingtheindicatorsetearlier.
exit
EOFarch1
#
#Step2:Recordwhichfilesareinthedestination
#directory.
#Dothisbysettinganenvironmentvariablethatis
#equaltothedirectorylistingforthedestination
#directory.
#Forthisexample,thelog_archive_destis
#/db01/oracle/arch/CC1.
#
FILES=`ls/db01/oracle/arch/CC1/arch*.dbf`;exportFILES
#
#Step3:GobackintoServerManagerandrestartthe
#archivingprocess.Setanindicator(calledEOFarch2
#inthisexample).
#
svrmgrl<<EOFarch2
connectinternalassysdba
archivelogstart;
exit
EOFarch2
#
#Step4.Backupthearchivedredologstothetape
#deviceviathe"tar"command,thendeletethem
#fromthedestinationdeviceviathe"rm"command.
#
tar-rvf/dev/rmt/0hc$FILES
#
#Step5.Deletethosefilesfromthedestinationdirectory.
#
rm-f$FILES
#
#Endofarchivedredologfilebackupscript.
REM磁盘到磁盘的备份
REM
REMBackuptheRBStablespace-toanotherdisk(UNIX)
REM
altertablespaceRBSbeginbackup;
!cp/db02/oracle/CC1/rbs01.dbf/db10/oracle/CC1/backups
altertablespaceRBSendbackup;
REM
REM移动归档日志文件的shell脚本
#
#Procedureformovingarchivedredologstoanotherdevice
#
svrmgrl<<EOFarch2
connectinternalassysdba
archivelogstop;
!mv/db01/oracle/arch/CC1/db10/oracle/arch/CC1
archivelogstart;
exit
EOFarch2
#
#endofarchivedredologdirectorymove.
//生成创建控制文件命令
alterdatabasebackupcontrolfiletotrace;
//时间点恢复的例子
connectinternalassysdba
startupmountinstance_name;
recoverdatabaseuntiltime’1999-08-07:14:40:00’;
//创建恢复目录
rmanrcvcatrman/rman@<database_service_name>
//在(UNIX)下创建恢复目录
RMAN>createcatalogtablespacercvcat;
//在(NT)下创建恢复目录
RMAN>createcatalogtablespace"RCVCAT";
//连接描述符范例
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=HQ)
(PORT=1521))
(CONNECTDATA=
(SID=loc)))
//listener.ora的条目entry
//创建一个控制文件命令到跟踪文件
alterdatabasebackupcontrolfiletotrace;
//增加一个新的日志文件组的语句
connectinternalassysdba
alterdatabase
addlogfilegroup4
(’/db01/oracle/CC1/log_1c.dbf’,
’/db02/oracle/CC1/log_2c.dbf’)size5M;
alterdatabase
addlogfilemember’/db03/oracle/CC1/log_3c.dbf’
togroup4;
//在ServerManager上MOUNT并打开一个数据库:
connectinternalassysdba
startupmountORA1exclusive;
alterdatabaseopen;
//生成数据字典
@catalog
@catproc
//在init.ora中备份数据库的位置
log_archive_dest_1=’/db00/arch’
log_archive_dest_state_1=enable
log_archive_dest_2="service=stby.worldmandatoryreopen=60"
log_archive_dest_state_2=enable
//对用户的表空间的指定和管理相关的语句
createuserUSERNAMEidentifiedbyPASSWORD
defaulttablespaceTABLESPACE_NAME;
alteruserUSERNAMEdefaulttablespaceTABLESPACE_NAME;
alteruserSYSTEMquota0onSYSTEM;
alteruserSYSTEMquota50MonTOOLS;
createuserUSERNAMEidentifiedbyPASSWORD
defaulttablespaceDATA
temporarytablespaceTEMP;
alteruserUSERNAMEtemporarytablespaceTEMP;
//重新指定一个数据文件的大小:
alterdatabase
datafile’/db05/oracle/CC1/data01.dbf’resize200M;
//创建一个自动扩展的数据文件:
createtablespaceDATA
datafile’/db05/oracle/CC1/data01.dbf’size200M
autoextendON
next10M
maxsize250M;
//在表空间上增加一个自动扩展的数据文件:
altertablespaceDATA
adddatafile’/db05/oracle/CC1/data02.dbf’
size50M
autoextendON
maxsize300M;
//修改参数:
alterdatabase
datafile’/db05/oracle/CC1/data01.dbf’
autoextendON
maxsize300M;
//在数据文件移动期间重新命名:
alterdatabaserenamefile
’/db01/oracle/CC1/data01.dbf’to
’/db02/oracle/CC1/data01.dbf’;
altertablespaceDATArenamedatafile
’/db01/oracle/CC1/data01.dbf’to
’/db02/oracle/CC1/data01.dbf’;
alterdatabaserenamefile
’/db05/oracle/CC1/redo01CC1.dbf’to
’/db02/oracle/CC1/redo01CC1.dbf’;
alterdatabasedatafile’/db05/oracle/CC1/data01.dbf’
resize80M;
//创建和使用角色:
createroleAPPLICATION_USER;
grantCREATESESSIONtoAPPLICATION_USER;
grantAPPLICATION_USERtousername;
//回滚段的管理
createrollbacksegmentSEGMENT_NAME
tablespaceRBS;
alterrollbacksegmentSEGMENT_NAMEoffline;
droprollbacksegmentSEGMENT_NAME;
alterrollbacksegmentSEGMENT_NAMEonline;
//回滚段上指定事务
commit;
settransactionuserollbacksegmentROLL_BATCH;
insertintoTABLE_NAME
select*fromDATA_LOAD_TABLE;
commit;
//查询回滚段的大小和优化参数
select*fromDBA_SEGMENTS
whereSegment_Type=’ROLLBACK’;
selectN.Name,/*rollbacksegmentname*/
S.OptSize/*rollbacksegmentOPTIMALsize*/
fromV$ROLLNAMEN,V$ROLLSTATS
whereN.USN=S.USN;
//回收回滚段
alterrollbacksegmentR1shrinkto15M;
alterrollbacksegmentR1shrink;
//例子
settransactionuserollbacksegmentSEGMENT_NAME
altertablespaceRBS
defaultstorage
(initial125Knext125Kminextents18maxextents249)
createrollbacksegmentR4tablespaceRBS
storage(optimal2250K);
alterrollbacksegmentR4online;
selectSessions_HighwaterfromV$LICENSE;
grantselectonEMPLOYEEtoPUBLIC;
//用户和角色
createroleACCOUNT_CREATOR;
grantCREATESESSION,CREATEUSER,ALTERUSER
toACCOUNT_CREATOR;
alteruserTHUMPERdefaultroleNONE;
alteruserTHUMPERdefaultroleCONNECT;
alteruserTHUMPERdefaultroleallexceptACCOUNT_CREATOR;
alterprofileDEFAULT
limitidle_time60;
createprofileLIMITED_PROFILElimit
FAILED_LOGIN_ATTEMPTS5;
createuserJANEidentifiedbyEYRE
profileLIMITED_PROFILE;
grantCREATESESSIONtoJANE;
alteruserJANEaccountunlock;
alteruserJANEaccountlock;
alterprofileLIMITED_PROFILElimit
PASSWORD_LIFE_TIME30;
alteruserjanepasswordexpire;
//创建操作系统用户
REMCreatingOPS$accounts
createuserOPS$FARMER
identifiedbySOME_PASSWORD
defaulttablespaceUSERS
temporarytablespaceTEMP;
REMUsingidentifiedexternally
createuserOPS$FARMER
identifiedexternally
defaulttablespaceUSERS
temporarytablespaceTEMP;
//执行ORAPWD
ORAPWDFILE=filenamePASSWORD=passwordENTRIES=max_users
createroleAPPLICATION_USER;
grantCREATESESSIONtoAPPLICATION_USER;
createroleDATA_ENTRY_CLERK;
grantselect,insertonTHUMPER.EMPLOYEEtoDATA_ENTRY_CLERK;
grantselect,insertonTHUMPER.TIME_CARDStoDATA_ENTRY_CLERK;
grantselect,insertonTHUMPER.DEPARTMENTtoDATA_ENTRY_CLERK;
grantAPPLICATION_USERtoDATA_ENTRY_CLERK;
grantDATA_ENTRY_CLERKtoMCGREGOR;
grantDATA_ENTRY_CLERKtoBPOTTERwithadminoption;
//设置角色
setroleDATA_ENTRY_CLERK;
setroleNONE;
//回收权利:
revokedeleteonEMPLOYEEfromPETER;
revokeallonEMPLOYEEfromMCGREGOR;
//回收角色:
revokeACCOUNT_CREATORfromHELPDESK;
dropuserUSERNAMEcascade;
grantSELECTonEMPLOYEEtoMCGREGORwithgrantoption;
grantSELECTonTHUMPER.EMPLOYEEtoBPOTTERwithgrantoption;
revokeSELECTonEMPLOYEEfromMCGREGOR;
createuserMCGREGORidentifiedbyVALUES’1A2DD3CCEE354DFA’;
alteruserOPS$FARMERidentifiedbyVALUES’noway’;
//备份与恢复
使用export程序
expsystem/managerfile=expdat.dmpcompress=Yowner=(HR,THUMPER)
expsystem/managerfile=hr.dmpowner=HRindexes=Ycompress=Y
impsystem/managerfile=hr.dmpfull=Ybuffer=64000commit=Y
//备份表
expsystem/managerFILE=expdat.dmpTABLES=(Thumper.SALES)
//备份分区
expsystem/managerFILE=expdat.dmpTABLES=(Thumper.SALES:Part1)
//输入例子
impsystem/managerfile=expdat.dmp
impsystem/managerfile=expdat.dmpbuffer=64000commit=Y
expsystem/managerfile=thumper.datowner=thumpergrants=N
indexes=Ycompress=Yrows=Y
impsystem/managerfile=thumper.datFROMUSER=thumperTOUSER=flower
rows=Yindexes=Y
impsystem/managerfile=expdat.dmpfull=Ycommit=Ybuffer=64000
impsystem/managerfile=expdat.dmpignore=Nrows=Ncommit=Ybuffer=64000
//使用操作系统备份命令
REMTARexamples
tar-cvf/dev/rmt/0hc/db0[1-9]/oracle/CC1
tar-rvf/dev/rmt/0hc/orasw/app/oracle/CC1/pfile/initcc1.ora
tar-rvf/dev/rmt/0hc/db0[1-9]/oracle/CC1/orasw/app/oracle/CC1/pfile/initcc1.ora
//离线备份的shell脚本
ORACLE_SID=cc1;exportORACLE_SID
ORAENV_ASK=NO;exportORAENV_ASK
.oraenv
svrmgrl<<EOF1
connectinternalassysdba
shutdownimmediate;
exit
EOF1
insertbackupcommandslikethe"tar"commandshere
svrmgrl<<EOF2
connectinternalassysdba
startup
EOF2
//在ServerManager上设置为archivelogmode:
connectinternalassysdba
startupmountcc1;
alterdatabasearchivelog;
archivelogstart;
alterdatabaseopen;
//在ServerManager上设置为archivelogmode:
connectinternalassysdba
startupmountcc1;
alterdatabasenoarchivelog;
alterdatabaseopen;
selectName,
Value
fromV$PARAMETER
whereNamelike’log_archive%’;
//联机备份的脚本
#
#SampleHotBackupScriptforaUNIXFileSystemdatabase
#
#Setupenvironmentvariables:
ORACLE_SID=cc1;exportORACLE_SID
ORAENV_ASK=NO;exportORAENV_ASK
.oraenv
svrmgrl<<EOFarch1
connectinternalassysdba
REM
REM备份SYSTEMtablespace
REM
altertablespaceSYSTEMbeginbackup;
!tar-cvf/dev/rmt/0hc/db01/oracle/CC1/sys01.dbf
altertablespaceSYSTEMendbackup;
REM
REMTheSYSTEMtablespacehasnowbeenwrittentoa
REMtarsavesetonthetapedevice/dev/rmt/0hc.The
REMrestofthetarsmustusethe"-rvf"clausetoappend
REMtothatsaveset.
REM
REM备份RBStablespace
REM
altertablespaceRBSbeginbackup;
!tar-rvf/dev/rmt/0hc/db02/oracle/CC1/rbs01.dbf
altertablespaceRBSendbackup;
REM
REM备份DATAtablespace
REMForthepurposesofthisexample,thistablespace
REMwillcontaintwofiles,data01.dbfanddata02.dbf.
REMThe*wildcardwillbeusedinthefilename.
REM
altertablespaceDATAbeginbackup;
!tar-rvf/dev/rmt/0hc/db03/oracle/CC1/data0*.dbf
altertablespaceDATAendbackup;
REM
REM备份INDEXEStablespace
REM
altertablespaceINDEXESbeginbackup;
!tar-rvf/dev/rmt/0hc/db04/oracle/CC1/indexes01.dbf
altertablespaceINDEXESendbackup;
REM
REM备份TEMPtablespace
REM
altertablespaceTEMPbeginbackup;
!tar-rvf/dev/rmt/0hc/db05/oracle/CC1/temp01.dbf
altertablespaceTEMPendbackup;
REM
REMFollowthesamepatterntobackuptherest
REMofthetablespaces.
REM
REM
REMStep2.备份归档日志文件.
archivelogstop
REM
REMExitServerManager,usingtheindicatorsetearlier.
exit
EOFarch1
#
#Recordwhichfilesareinthedestinationdirectory.
#Dothisbysettinganenvironmentvariablethatis
#equaltothedirectorylistingforthedestination
#directory.
#Forthisexample,thelog_archive_destis
#/db01/oracle/arch/CC1.
#
FILES=`ls/db01/oracle/arch/CC1/arch*.dbf`;exportFILES
#
#NowgobackintoServerManagerandrestartthe
#archivingprocess.Setanindicator(calledEOFarch2
#inthisexample).
#
svrmgrl<<EOFarch2
connectinternal
archivelogstart;
exit
EOFarch2
#
#Nowbackupthearchivedredologstothetape
#deviceviathe"tar"command,thendeletethem
#fromthedestinationdeviceviathe"rm"command.
#Youmaychoosetocompresstheminstead.
#
tar-rvf/dev/rmt/0hc$FILES
rm-f$FILES
#
#Step3.备份控制文件到磁盘.
#
svrmgrl<<EOFarch3
connectinternal
alterdatabasebackupcontrolfileto
’db01/oracle/CC1/CC1controlfile.bck’;
exit
EOFarch3
#
#备份控制文件到磁带.
#
tar-rvf/dev/rmt/0hc/db01/oracle/CC1/CC1controlfile.bck
#
#Endofhotbackupscript.
//自动生成开始备份的脚本
setpagesize0feedbackoff
select
’altertablespace’||Tablespace_Name||’beginbackup;’
fromDBA_TABLESPACES
whereStatus<>’INVALID’
spoolalter_begin.sql
/
spooloff
//自动生成备份结束的脚本
setpagesize0feedbackoff
select
’altertablespace’||Tablespace_Name||’endbackup;’
fromDBA_TABLESPACES
whereStatus<>’INVALID’
spoolalter_end.sql
/
spooloff
//备份归档日志文件的脚本.
REMSeetextforalternatives.
#Step1:Stopthearchivingprocess.Thiswillkeep
#additionalarchivedredologfilesfrombeingwritten
#tothedestinationdirectoryduringthisprocess.
#
svrmgrl<<EOFarch1
connectinternalassysdba
archivelogstop;
REM
REMExitServerManagerusingtheindicatorsetearlier.
exit
EOFarch1
#
#Step2:Recordwhichfilesareinthedestination
#directory.
#Dothisbysettinganenvironmentvariablethatis
#equaltothedirectorylistingforthedestination
#directory.
#Forthisexample,thelog_archive_destis
#/db01/oracle/arch/CC1.
#
FILES=`ls/db01/oracle/arch/CC1/arch*.dbf`;exportFILES
#
#Step3:GobackintoServerManagerandrestartthe
#archivingprocess.Setanindicator(calledEOFarch2
#inthisexample).
#
svrmgrl<<EOFarch2
connectinternalassysdba
archivelogstart;
exit
EOFarch2
#
#Step4.Backupthearchivedredologstothetape
#deviceviathe"tar"command,thendeletethem
#fromthedestinationdeviceviathe"rm"command.
#
tar-rvf/dev/rmt/0hc$FILES
#
#Step5.Deletethosefilesfromthedestinationdirectory.
#
rm-f$FILES
#
#Endofarchivedredologfilebackupscript.
REM磁盘到磁盘的备份
REM
REMBackuptheRBStablespace-toanotherdisk(UNIX)
REM
altertablespaceRBSbeginbackup;
!cp/db02/oracle/CC1/rbs01.dbf/db10/oracle/CC1/backups
altertablespaceRBSendbackup;
REM
REM移动归档日志文件的shell脚本
#
#Procedureformovingarchivedredologstoanotherdevice
#
svrmgrl<<EOFarch2
connectinternalassysdba
archivelogstop;
!mv/db01/oracle/arch/CC1/db10/oracle/arch/CC1
archivelogstart;
exit
EOFarch2
#
#endofarchivedredologdirectorymove.
//生成创建控制文件命令
alterdatabasebackupcontrolfiletotrace;
//时间点恢复的例子
connectinternalassysdba
startupmountinstance_name;
recoverdatabaseuntiltime’1999-08-07:14:40:00’;
//创建恢复目录
rmanrcvcatrman/rman@<database_service_name>
//在(UNIX)下创建恢复目录
RMAN>createcatalogtablespacercvcat;
//在(NT)下创建恢复目录
RMAN>createcatalogtablespace"RCVCAT";
//连接描述符范例
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=HQ)
(PORT=1521))
(CONNECTDATA=
(SID=loc)))
//listener.ora的条目entry
LISTENER=
(ADDRESS_LIST=
(ADDRESS=
(PROTOCOL=IPC)
转贴于 学生大读书网 http://
(KEY=loc.world)
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=loc)
(ORACLE_HOME=/orasw/app/oracle/product/8.1.5.1)
)
)
//tnsnames.ora的条目
LOC=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=HQ)
(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=loc)
(INSTANCE_NAME=loc)
)
)
//连接参数的设置(sql*net)
LOC=(DESCRIPTION=
(ADDRESS=
(COMMUNITY=TCP.HQ.COMPANY)
(PROTOCOL=TCP)
(HOST=HQ)
(PORT=1521))
(CONNECTDATA=
(SID=loc)))
//参数文件配置范例
//tnsnames.ora
HQ=(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=HQ)
(PORT=1521))
(CONNECTDATA=
(SID=loc)))
//listener.ora
LISTENER=
(ADDRESS_LIST=
(ADDRESS=
(PROTOCOL=IPC)
(KEY=loc)
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=loc)
(ORACLE_HOME=/orasw/app/oracle/product/8.1.5.1)
)
)
//Oracle8Itnsnames.ora
LOC=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=HQ)
(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=loc)
(INSTANCE_NAME=loc)
)
)
//使用COPY实现数据库之间的复制
copyfrom
remote_username/remote_password@service_name
to
username/password@service_name
[append|create|insert|replace]
TABLE_NAME
usingsubquery;
REMCOPYexample
setcopycommit1
setarraysize1000
copyfromHR/PUFFINSTUFF@loc-
createEMPLOYEE-
using-
select*fromEMPLOYEE
//监视器的管理
lsnrctlstart
lsnrctlstartmy_lsnr
lsnrctlstatus
lsnrctlstatushq
检查监视器的进程
ps-ef|greptnslsnr
//在lsnrctl内停止监视器
setpasswordlsnr_password
stop
//在lsnrctl内列出所有的服务
setpasswordlsnr_password
services
//启动或停止一个NT的listener
netstartOracle<version_name>TNSListener
netstopOracle<version_name>TNSListener
//tnsnames.ora文件的内容
fld1=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)
(HOST=server1.fld.com)(PORT=1521))
)
(CONNECT_DATA=
(SID=fld1)
)
)
//操作系统网络的管理
telnethost_name
pinghost_name
/etc/hosts文件
130.110.238.109nmhost
130.110.238.101txhost
130.110.238.102azhostarizona
//oratab表项
loc:/orasw/app/oracle/product/8.1.5.1:Y
cc1:/orasw/app/oracle/product/8.1.5.1:N
old:/orasw/app/oracle/product/8.1.5.0:Y