SQL Server:
备份命令:
BACKUP DATABASE test
TO disk = 'c:\test'
WITH FORMAT,
NAME = 'Full Backup of MyNwind'
通过shell脚本调用sql脚本:1、shell脚本调用sql脚本
#首先编辑sql文件
oracle@SZDB:~>more dept.sql
connect scott/tiger
spool /tmp/dept.lst
set linesize 100 pagesize 80
select * from dept
spool off
exit
#编辑shell脚本文件,在shell脚本内调用sql脚本
oracle@SZDB:~>more get_dept.sh
#!/bin/bash
# set environment variable
if [ -f ~/.bashrc ]then
. ~/.bashrc
fi
export ORACLE_SID=CNMMBO
sqlplus -S /nolog @/users/oracle/dept.sql #注意此处执行sql脚本的方法 -S 表示以静默方式执行
exit
#授予脚本执行权限
oracle@SZDB:~>chmod 775 get_dept.sh
-->执行shell脚本
oracle@SZDB:~>./get_dept.sh
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
2、shell脚本调用rman脚本
#首先编辑RMAN脚本
oracle@SZDB:~>more rman.rcv
RUN {
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS
CONFIGURE BACKUP OPTIMIZATION ON
CONFIGURE CONTROLFILE AUTOBACKUP ON
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/users/oracle/bak/%d_%F'
ALLOCATE CHANNEL CH1 TYPE DISK MAXPIECESIZE=4G
ALLOCATE CHANNEL CH2 TYPE DISK MAXPIECESIZE=4G
SET LIMIT CHANNEL CH1 READRATE=10240
SET LIMIT CHANNEL CH1 KBYTES=4096000
SET LIMIT CHANNEL CH2 READRATE=10240
SET LIMIT CHANNEL CH2 KBYTES=4096000
CROSSCHECK ARCHIVELOG ALL
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL
BACKUP
DATABASE FORMAT '/users/oracle/bak/%d_FULL__%U'
SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT'
BACKUP ARCHIVELOG ALL FORMAT '/users/oracle/bak/%d_LF_%U' DELETE INPUT
DELETE NOPROMPT OBSOLETE
RELEASE CHANNEL CH1
RELEASE CHANNEL CH2
}
#编辑shell脚本文件,在shell脚本内调用rman脚本
oracle@SZDB:~>more rman_bak.sh
#!/bin/bash
# set environment variable
if [ -f ~/.bashrc ]then
. ~/.bashrc
fi
export ORACLE_SID=CNMMBO
$ORACLE_HOME/bin/rman target / cmdfile=/users/oracle/rman.rcv log=/users/oracle/bak/rman.log
exit
#授予脚本执行权限
oracle@SZDB:~>chmod 775 rman_bak.sh
#执行shell脚本
是给现有的字段名另指定一个别名的意思,比如: select username as 用户名,password as 密码 from users 补充:比如其中的一个好处是:当字段名是英文或拼音缩写时,采用汉字替代之后可以给阅读带来方便是给现有的字段名另指定一个别名的意思,比如: select username as 用户名,password as 密码 from users 补充:比如其中的一个好处是:当字段名是英文或拼音缩写时,采用汉字替代之后可以给阅读带来方便
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)