web analytics

Using SQL*Plus in Oracle

Options

codeling 1595 - 6639
@2016-02-18 10:53:01

SQL*Plus is an interactive and batch query tool that is installed with every Oracle Database installation. It has a command-line user interface, a Windows Graphical User Interface (GUI) and the iSQL*Plus web-based user interface.

SQL*Plus has its own commands and environment, and it provides access to the Oracle Database. It enables you to enter and execute SQL, PL/SQL, SQL*Plus and operating system commands to perform the following:

  • Format, perform calculations on, store, and print from query results
  • Examine table and object definitions
  • Develop and run batch scripts
  • Perform database administration

 

@2016-02-18 11:00:05

Starting SQL*Plus Command-line

The SQL*Plus executable is usually installed in $ORACLE_HOME/bin, which is usually included in your operating system PATH environment variable. You may need to change directory to the $ORACLE_HOME/bin directory to start SQL*Plus.

In the following examples, you enter the SQL*Plus command to login devdb with the user id and password:

c:\>sqlplus username/passwor@devdb
@2016-02-18 11:03:07

Execute a SQL script file in SQLPlus

To execute a script file in SQLPlus, type @ and then the file name.

SQL > @{file}

For example, if your file was called script.sql, you'd type the following command at the SQL prompt:

SQL > @script.sql
@2016-02-18 11:45:39

Run Oracle SQL script and exit from sqlplus.exe via command prompt

Question

I would like to run an Oracle script through SQL Plus via a Windows command prompt. The script does not contain an "exit" command, but I would still like SQL Plus to exit, returning control to the command prompt on completion of the script. My goal is to do this without modifying the script. Is this possible?

Solution

use this command in the batch file:

echo exit | sqlplus user/pass@connect @scriptname

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com