run1.sql
SET ECHO OFF;
SET FEEDBACK OFF;
SET HEADING OFF;
SET LINESIZE 300;
select 'update compartment set tenant_name='''||name||''' where tenant_id='''||customer_id||''';' from customer;
执行命令
sqlplus64 username/password@database @/opt/token/run1.sql
结果:
SQL*Plus: Release 11.2.0.3.0 Production on Mon Apr 13 05:38:07 2020
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
update compartment set tenant_name='abc' where tenant_id='101
1';
如何消除以下信息并只列出查询结果
SQL*Plus: Release 11.2.0.3.0 Production on Mon Apr 13 05:38:07 2020
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
我试着"出发"。但它没有起作用。
这是一个基于Scott的示例dept
表的MS Windows示例。
如果您创建了.sql文件(对我来说是p.sql
(:
SET ECHO OFF;
SET FEEDBACK OFF;
SET HEADING OFF;
SET LINESIZE 100;
spool p.txt
select * From dept;
spool off
和一个操作系统.bat文件(对我来说是p.bat
(:
sqlplus scott/tiger @p.sql
和-在操作系统命令提示符下调用批处理文件(而不是使用所需的.sql脚本直接调用sqlplus
!(,结果如下:
c:Temp>p
c:Temp>sqlplus scott/tiger @p.sql
SQL*Plus: Release 11.2.0.2.0 Production on Uto Tra 14 10:09:23 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL>
但是,生成的假脱机文件(p.txt
(如下所示:
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
所以,只有数据。我建议你也这样做。