![](/img/trans.png)
[英]How can I connect to Oracle Database with SQLcl and SQLPlus, but without a TNSNames.ORA file?
[英]SQLCL console print to file instead of stdout
我有一個 .bat 文件,它看起來像這樣:
start C:\sqlcl-latest\sqlcl\bin\sql javi/pwd@tnsname @"mypath1"
它調用的腳本如下所示:
select 1 from dual;
select 2 from dual;
exit;
有沒有辦法將 cmd 和 sqlcl 控制台中的所有內容記錄到一個文件中,而不是/除了在標准輸出中打印?
我試過下面的方法,但它創建了一個空的日志文件:
start C:\sqlcl-latest\sqlcl\bin\sql javi/pwd@tnsname @"mypath1" > mylog.txt
我沒有 SQLCL,但是這個(重定向到文件)應該(至少,我希望如此)在操作系統命令提示符下工作。
我的文件 1.sql:
select * from dept;
我的文件 2.sql:
select empno, ename, job, sal
from emp
where deptno = 10;
我的路徑1.sql:
@"myfile1"
@"myfile2"
exit;
我的蝙蝠.bat:
sqlplus scott/tiger@orcl@mypath1.sql > mylog.txt
-----------
this redirects output into mylog.txt file
在命令提示符下運行mybat.bat
:
C:\>mybat
C:\>sqlplus scott/tiger@orcl@mypath1.sql 1>mylog.txt
沒有要篩選的output; 一切都包含在mylog.txt
文件中 - 讓我們檢查一下:
C:\>type mylog.txt
SQL*Plus: Release 18.0.0.0.0 - Production on Čet Sij 19 08:18:58 2023
Version 18.5.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Active code page: 1250
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
EMPNO ENAME JOB SAL
---------- ---------- --------- ----------
7782 CLARK MANAGER 2450
7839 KING PRESIDENT 5000
7934 MILLER CLERK 1300
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
C:\>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.