单引号与动态sql的几个例子

(查杀rman进程的批量脚本,也可用于查杀其他有明显客户标示的进程)
  1  select 'alter system kill session  '||''''||b.sid||','||b.serial#||''''||';'
  2  from v$process a,v$session b
  3* where a.addr=b.paddr and b.client_info like'rman%'
'ALTERSYSTEMKILLSESSION'||''''||B.SID||','||B.SERIAL#||''''||';'
--------------------------------------------------------------------------------
alter system kill session  '146,19';
alter system kill session  '137,66';
alter system kill session  '143,45';
alter system kill session  '145,54';
alter system kill session  '154,380';
SQL> SELECT 'SELECT DBMS_METADATA.GET_DDL('||''''||'VIEW'||''''||','||''''||VIEW_NAME||''''||')'||'FROM DUAL'||';' FROM
USER_VIEWS;
'SELECTDBMS_METADATA.GET_DDL('||''''||'VIEW'||''''||','||''''||VIEW_NAME||''''|
-------------------------------------------------------------------------------
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_PROXY_ARCHIVELOG_SUMMARY')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_UNUSABLE_BACKUPFILE_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_RMAN_BACKUP_TYPE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_DATABASE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_DATABASE_INCARNATION')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_RESYNC')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_CHECKPOINT')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_TABLESPACE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_DATAFILE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_TEMPFILE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_REDO_THREAD')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_REDO_LOG')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_LOG_HISTORY')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_ARCHIVED_LOG')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_SET')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_PIECE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_DATAFILE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_CONTROLFILE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_SPFILE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_DATAFILE_COPY')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_CONTROLFILE_COPY')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_REDOLOG')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_CORRUPTION')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_COPY_CORRUPTION')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_OFFLINE_RANGE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_STORED_SCRIPT')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_STORED_SCRIPT_LINE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_PROXY_DATAFILE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_PROXY_CONTROLFILE')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_RMAN_CONFIGURATION')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_DATABASE_BLOCK_CORRUPTION')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_PROXY_ARCHIVEDLOG')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_RMAN_STATUS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_RMAN_OUTPUT')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_FILES')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_RMAN_BACKUP_SUBJOB_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_RMAN_BACKUP_JOB_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_SET_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_PIECE_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_COPY_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_PROXY_COPY_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_PROXY_ARCHIVELOG_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_DATAFILE_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_CONTROLFILE_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_ARCHIVELOG_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_SPFILE_DETAILS')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_SET_SUMMARY')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_DATAFILE_SUMMARY')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_CONTROLFILE_SUMMARY')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_ARCHIVELOG_SUMMARY')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_SPFILE_SUMMARY')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_BACKUP_COPY_SUMMARY')FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','RC_PROXY_COPY_SUMMARY')FROM DUAL;
53 rows selected
SQL> select '''' from dual;
'
-
'

标签: 暂无标签
dongxujian

写了 86 篇文章,拥有财富 384,被 13 人关注

转播转播 分享分享 分享淘帖
回复

使用道具

成为第一个吐槽的人

您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

意见
反馈