Using SQL*Plus in Oracle Options

codeling Posts: 1057 Points: 4443
Posted: Thursday, February 18, 2016 10:53:01 AM

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

 


codeling Posts: 1057 Points: 4443
Posted: Thursday, February 18, 2016 11:00:05 AM

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

codeling Posts: 1057 Points: 4443
Posted: Thursday, February 18, 2016 11:03:07 AM

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

codeling Posts: 1057 Points: 4443
Posted: Thursday, February 18, 2016 11:45:39 AM

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
Users browsing this topic
Guest