执行SQL
记录日志
spool sqlfile.sql.log
prompt Runing sqlfile.sql
@sqlfile.sql
清理日志和创建监控
grant create session to USERNAME;
grant select any dictionary to USERNAME;
grant CREATE PROCEDURE to USERNAME;
grant create table to USERNAME;
grant create synonym to USERNAME;
grant create view to USERNAME;
grant create sequence to USERNAME;
grant debug any procedure to USERNAME;
grant DEBUG CONNECT SESSION to USERNAME;
grant SELECT ANY SEQUENCE to USERNAME;
grant select any table to USERNAME;
grant create trigger to USERNAME;
grant unlimited tablespace to USERNAME;
grant ALTER ANY MATERIALIZED VIEW to USERNAME;
生成SQL
set line 1000
set linesize 256
set pagesize 9999
set long 999999
set heading off
col myrow format a200
set feedback off;
set echo off ;
spool procedures.sql ;
SELECT DBMS_METADATA.GET_DDL('INDEX','TABLE','USER') FROM DUAL;
spool off;
物化视图刷新
exec dbms_mview.refresh('USERNAME.MView','C');
call dbms_mview.refresh('USERNAME.MView', 'C');
select 'exec dbms_mview.refresh('''||OWNER||'.'||OBJECT_NAME||''',''C'');' from dba_objects where owner='USERNAME' and object_type='MATERIALIZED VIEW'
统计信息更新
sqlplus -s CMO/CMOOMC@${instance} << EOF
exec dbms_stats.gather_schema_stats(ownname => '${schema}',estimate_percent => dbms_stats.auto_sample_size);
exit;
EOF
脚本执行SQL
sqlplus -S $tsnstr << EOF > /dev/null 2>&1
set line 1000;
set pagesize 9999;
set trimout on;
set trimspool on;
set termout off;
set time on;
set timing on;
@"$SQLFILE"
commit;
exit;
EOF
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义