Search notes:

SQL*Plus: Run SQL scripts from the command line

The @ symbol can be used on the command line when invoking SQL*Plus to start an SQL script file:
$ sqlplus usr/pw@db @script.sql

PowerShell

Highlight warnings and errors

In PowerShell, it is possible to pipe the output of into a pipeline that embeds the text error or warning into ANSI escape sequences so that these two words are highlighted:
sqlplus rene/secretGarden@Ora19 `@script | foreach-object { $line = $_; $line = $line -replace '^(error|warning).*|^SP2-', "$([char]27)[38;5;9m$line$([char]27)[0m" ; $line }
Note: in the example above, the @ before the script name must be escaped with the back-tick (PowerShell's escape character).

Execute a single statement

The following example executes a single SQL statement by piping it into the SQL*Plus executable. The statement is followed by a new line (`n) and exit so that sqlplus returns to the shell again:
PS> "grant select on customer to sales;`nexit" | sqlplus [admin]@db

Index