使用sql生成sql指令碼
1,設定環境變數
SQL>set echo off
SQL>set heading off
SQL>set feedback off
SQL>set echo off
SQL>set heading off
SQL>set feedback off
2,把SQL*plus中執行的內容追加到一個檔案中:
SQl>spool D:\oracle\grant.txt
SQl>spool D:\oracle\grant.txt
3,執行SQL,查詢結果會寫到D:\oracle\grant.txt檔案中
SQL> select 'grant connect,resource to'||username||';' from dba_users;
SQL> select 'grant connect,resource to'||username||';' from dba_users;
部分輸出內容
grant connect,resource toSYS;
grant connect,resource toSYSTEM;
grant connect,resource toSCOTT;
grant connect,resource toTEST;
grant connect,resource toRMAN;
grant connect,resource toOUTLN;
grant connect,resource toMGMT_VIEW;
grant connect,resource toMDSYS;
grant connect,resource toORDSYS;
grant connect,resource toCTXSYS;
grant connect,resource toANONYMOUS;
grant connect,resource toEXFSYS;
grant connect,resource toDMSYS;
grant connect,resource toSYS;
grant connect,resource toSYSTEM;
grant connect,resource toSCOTT;
grant connect,resource toTEST;
grant connect,resource toRMAN;
grant connect,resource toOUTLN;
grant connect,resource toMGMT_VIEW;
grant connect,resource toMDSYS;
grant connect,resource toORDSYS;
grant connect,resource toCTXSYS;
grant connect,resource toANONYMOUS;
grant connect,resource toEXFSYS;
grant connect,resource toDMSYS;
4,檢視grant.txt的內容:
grant connect,resource toSYS;
grant connect,resource toSYSTEM;
grant connect,resource toSCOTT;
grant connect,resource toTEST;
grant connect,resource toRMAN;
grant connect,resource toOUTLN;
grant connect,resource toMGMT_VIEW;
grant connect,resource toMDSYS;
grant connect,resource toORDSYS;
grant connect,resource toCTXSYS;
grant connect,resource toANONYMOUS;
grant connect,resource toEXFSYS;
grant connect,resource toDMSYS;
... ...
grant connect,resource toSYS;
grant connect,resource toSYSTEM;
grant connect,resource toSCOTT;
grant connect,resource toTEST;
grant connect,resource toRMAN;
grant connect,resource toOUTLN;
grant connect,resource toMGMT_VIEW;
grant connect,resource toMDSYS;
grant connect,resource toORDSYS;
grant connect,resource toCTXSYS;
grant connect,resource toANONYMOUS;
grant connect,resource toEXFSYS;
grant connect,resource toDMSYS;
... ...
5,執行指令碼
SQL>@D:\oracle\grant.txt
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
... ...
SQL>@D:\oracle\grant.txt
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
... ...
哦了,大功告成,簡單的一個方法,解決了大批次執行某項操作時的繁瑣。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25373498/viewspace-748913/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SQL Server映象自動生成指令碼方法SQLServer指令碼
- PowerDesigner: 利用sql指令碼檔案逆生成模型SQL指令碼模型
- django指令碼orm中使用原生sqlDjango指令碼ORMSQL
- mybatis執行sql指令碼MyBatisSQL指令碼
- SQL SERVER巡檢指令碼SQLServer指令碼
- [20240313]使用tpt ashtop.sql指令碼的困惑.txtSQL指令碼
- catalog.sql指令碼介紹SQL指令碼
- sql_trace相關指令碼SQL指令碼
- SQL 的後計算指令碼SQL指令碼
- [20231101]使用tpt seg2.sql指令碼問題.txtSQL指令碼
- [20231117]完善ashtt.sql指令碼.txtSQL指令碼
- [20211230]完善sql_id指令碼.txtSQL指令碼
- [20211122]完善descx.sql指令碼.txtSQL指令碼
- [20221012]完善spsw.sql指令碼.txtSQL指令碼
- [20221010]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善gts.sql指令碼.txtSQL指令碼
- [20230203]完善awr.sql指令碼.txtSQL指令碼
- [20230123]完善curheapz.sql指令碼.txtSQL指令碼
- [20210407]完善ti.sql指令碼.txtSQL指令碼
- [20210125]完善hide.sql指令碼.txtIDESQL指令碼
- 10個SQL技巧之二:使用遞迴SQL生成資料SQL遞迴
- 探究Presto SQL引擎(3)-程式碼生成RESTSQL
- [20241110]使用xto10.sql指令碼遇到的問題.txtSQL指令碼
- jsqlparser使用記錄---生成sql語句JSSQL
- [20191111]完善bind_cap.sql指令碼.txtSQL指令碼
- [20220217]完善tpt gts.sql指令碼.txtSQL指令碼
- [20220510]完善tpt expandz.sql指令碼.txtSQL指令碼
- [20211202]完善d_buffer.sql指令碼.txtSQL指令碼
- [20211129]完善tpt tablist.sql指令碼.txtSQL指令碼
- [20211130]完善tpt t.sql指令碼.txtSQL指令碼
- [20211129]完善tpt killi.sql指令碼.txtSQL指令碼
- [20211129]更新dpcawr1.sql指令碼.txtPCASQL指令碼
- [20211126]完善tpt pr.sql指令碼.txtSQL指令碼
- [20230414]完善seg2.sql指令碼.txtSQL指令碼
- [20230210]建立完善swcnm.sql指令碼.txtSQL指令碼
- [20221208]完善bind_cap.sql指令碼.txtSQL指令碼
- [20220309]完善shp4.sql指令碼.txtSQL指令碼
- [20210428]改進pr.sql指令碼.txtSQL指令碼