如何通过 sql plus 从命令行发出单个命令?

How can I issue a single command from the command line through sql plus?(如何通过 sql plus 从命令行发出单个命令?)
本文介绍了如何通过 sql plus 从命令行发出单个命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 SQL Plus,您可以从命令行运行带有@"运算符的脚本,如下所示:

Using SQL Plus, you can run a script with the "@" operator from the command line, as in:

c:>sqlplus username/password@databasename @"c:my_script.sql"

但是是否可以只运行具有类似语法的单个命令,而不需要一个完整的单独脚本文件?如:

But is it possible to just run a single command with a similar syntax, without a whole separate script file? As in:

c:>sqlplus username/password@databasename @execute some_procedure

我对这个很感兴趣,因为我想写一个批处理文件,只执行一个命令,而不生成一堆两行.sql"文件.

I am interested in this because I want to write a batch file that simply executes a command, without generating a bunch of two-line ".sql" files.

推荐答案

我能够通过将 SQL 查询通过管道传输到 SQL*Plus 来运行它:

I'm able to run an SQL query by piping it to SQL*Plus:

@echo select count(*) from table; | sqlplus username/password@database

给予

@echo execute some_procedure | sqlplus username/password@databasename

试一试.

这篇关于如何通过 sql plus 从命令行发出单个命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)