REQUEST COMPLIMENTARY SQLS*PLUS LICENCE
Chapter 4: List of SQLS*Plus Commands
List of Commands:
Command
| Usage
| Description
| |||||||||||||||||||||||||||
& | &<variable name> | Use substitution variable | |||||||||||||||||||||||||||
&& | &&<variable name> | Use substitution variable | |||||||||||||||||||||||||||
/ | Executes the SQL command or batch currently stored in the SQL buffer | ||||||||||||||||||||||||||||
ACCEPT|ACC | ACC[EPT] variable [DEF[AULT] default] [PROMPT text| NOPR[OMPT]] [HIDE] | Reads keyboard input and stores it into the SQLS*Plus variable (listed by DEFINE command) variable DEF[AULT] PROMPT text NOPR[OMPT] HIDE | |||||||||||||||||||||||||||
AGAIN |!! | Again | !!<number> | Rerun latest matching entry or command from history | |||||||||||||||||||||||||||
BREAK|BRE | BREAK [ON <COLUMN|REPORT|ROW>] <DUP|NODUP> ON specifies on what <SKI[P] N|PAGE> | column to track value changes that occur in the report and the formatting action to perform ON REPORT specifies that break related action (SKIP lines or calculate COMP values) will be done at the ON ROW executes SKIP action (if specified) after every row DUP|NODUP NODUP prints blanks for duplicate values in break column DUP prints the value of a break column in every row SKIP skips specified number of lines or whole page on break BREAK is needed for COMP statements to work COMP expects to have BREAK columns defined for ON part of the COMP statement | |||||||||||||||||||||||||||
BTITLE | BTI[TLE] [printspec [text | variable] …] | [ON | OFF] Syntax where printspec represents one or more of the following clauses used to place and format the text: CE[NTER] LE[FT] S[KIP] [n] COL [n] TAB [n] Enter BTITLE with no clauses to list the current BTITLE definition. Options See the TTITLE command for information on terms and clauses in the BTITLE command syntax. Examples BTITLE LEFT ‘REPORT ‘ RIGHT ‘PAGE:’ | Places and formats a specified title at the bottom of each report page, or lists the current BTITLE definition. See the TTITLE command syntax for information on terms and clauses in the R[IGHT] BTITLE command syntax. | |||||||||||||||||||||||||||
CAT | cat <table_name> -a | Synonym for “select * from <table/view name” Cat <table/view name> Selects first 3000 rows Options: -a – select all rows | |||||||||||||||||||||||||||
CD | cd <directory_name> | Change current directory location | |||||||||||||||||||||||||||
CLEAR | clear <BREAKS|COMPUTES|SCREEN> | BRE[AKS] – clears all defined breaks COMP[UTES] – clears all defined computes SCR[EEN] – clear screen | |||||||||||||||||||||||||||
COLUMN | COL | COLUMN | COL col <name> heading <name> format <format> <ON|OFF> <PRINT|NOPRINT>Supported Character Formats To change the width of a character field to n, use FORMAT An. (“A” for alphabetic.)Supported Num ber Formats
| Set column format ON|OFF – turn off/on column format attributes PRINT|NOPRINT – show or hide column from the query output | |||||||||||||||||||||||||||
COMPUTE|COMP | COMP[UTE] [function [LAB[EL] text] … OF {column } … ON {column} Supported functions:
| COMP in combination with the BREAK, calculates and prints summary function values, based on groups defined by BREAK. COMP with no parameters lists all current COMPUTE definitions. LABEL Defines the label for the computed function value OF {column} OF defines columns that is used to calculate value summary of function ON {column} ON defines columns that is used to group values summary functions around. Corresponding BREAK ON columns must exists for ON clause in COMP to work If multiple | |||||||||||||||||||||||||||
CONNECT | CONN | connect user/password@ip[\\instance_name][:db_name]
| Create a new session Connect creates a database session. Multiple sessions can exists at the same time Instance name and database names are optional Instead of db_name it is possible to use below environmental variables to set up default database for connection: a) SQLSDBNAME b) SQLCMDDBNAM E (standard sqlcmd variable) | |||||||||||||||||||||||||||
COUNT | Count rows in the tables | ||||||||||||||||||||||||||||
DEFINE | DEF[INE] [variable]|[variable = text] -l list defines Below are the pre-defined variables _CONNECT_IDENTIFIER Connection identifier used to make connection. _CONNECT_DATABASE Database used to make connection, where available. _EDITOR _S_VERSION _S_LEVEL _USER | Define a variable and assigns a value to it, or lists the value and variable type of a single variable or all variables | |||||||||||||||||||||||||||
CTAS | CTAS source_table destination_table empty_flag | Create destination table as select from the source table | |||||||||||||||||||||||||||
DEPS | DEPS [NAME] -r list dependencies recursively | Object dependencies and references | |||||||||||||||||||||||||||
DESCRIBE | DESC | DE | DESCRIBE [OBJECT_NAME|SCHEMA.OBJECT_ NAME] [detail] | Describe a table, view or a stored procedure “detail” option provides detailed describe information | |||||||||||||||||||||||||||
DIR | List file directory | ||||||||||||||||||||||||||||
DISCONNECT | Disconnect session | ||||||||||||||||||||||||||||
EDIT | ED | ED | ED <sql_file_name> | Edit current statement or sql script file Default editor is “notepad” Environment variable SQLSEDIT can be used to set custom editor | |||||||||||||||||||||||||||
EXEC | Execute T-SQL procedure | ||||||||||||||||||||||||||||
FIND | Find a line in T-SQL procedure source | ||||||||||||||||||||||||||||
GREP | grep <pattern table [extra clause]> -v show rows that don’t match pattern -I ignore case Search pattern across all table columns | Show rows that match pattern | |||||||||||||||||||||||||||
HEAD | Show first rows of table | ||||||||||||||||||||||||||||
HELP | Provide help for a command | ||||||||||||||||||||||||||||
HISTORY | HIST | HI | Show history items matching pattern (or all) | ||||||||||||||||||||||||||||
HOST | HOS | HO | Execute host OS command | ||||||||||||||||||||||||||||
ID | Display current user and login | ||||||||||||||||||||||||||||
LIST | List last sql statement | ||||||||||||||||||||||||||||
LS | List all objects matching pattern | ||||||||||||||||||||||||||||
PAUSE | SET PAUSE <TEXT> SET PAUSE [ON|OFF] | Enables to control scrolling of terminal when executing reports. First step is to “SET PAUSE text”, and then “SET PAUSE ON” to make text to appear each time SQLS*Plus pauses. | |||||||||||||||||||||||||||
PRINTVAR | Print bind variables | ||||||||||||||||||||||||||||
PROMPT | Sends the specified message or a blank line to the user’s screen | ||||||||||||||||||||||||||||
PURGE | purge <table where …> -c print table count at the end -n 1000 chunk size You can specify an additional “where” clause: purge Table where id=23 | Delete from (large) table in chunks Purge executes a series (-i) of delete statements, where each statement deletes (-n) rows at a time and commits. | |||||||||||||||||||||||||||
PWD | Show current directory | ||||||||||||||||||||||||||||
QUIT | Leave SQLS*Plus | ||||||||||||||||||||||||||||
RECOMPILE | Recompile objects | ||||||||||||||||||||||||||||
REFS | Display referential integrity dependencies | ||||||||||||||||||||||||||||
REM | |||||||||||||||||||||||||||||
RERUN | !! | rerun <history_number> | Run history item number | |||||||||||||||||||||||||||
SET AUTOCOMMIT | set auto[commit] <on|imm[ediate]|off> | Controls when SQL Server commits changes to the database after SQL commands or T-SQL call. ON commits changes to the database after SQL Server executes successful DML or T-SQL call. OFF turns off automatic committing so commit changes has to be done explicitly. IMMEDIATE is a synonym of ON. | |||||||||||||||||||||||||||
SET AUTOFORMAT | set autoformat <table_name> maxsize <N> sample <N> maxsize default is 40 characters sample default is 10% of table size | Automatically generates optimal format definitions for table %char% and %int% columns based of sampling of table data Maxsize defines maximum column size for long character columns Sample defines what percent of the table data to scan to create optimal format definitions | |||||||||||||||||||||||||||
SET COLSEP | Set column separator character | ||||||||||||||||||||||||||||
SET FEEDBACK | set feedback <on|off|N> | Display number of records returned by a query when a query selects at least n records N – when number of selected records is over N, number of records returned will be shown | |||||||||||||||||||||||||||
SET HEADING | Set heading value | ||||||||||||||||||||||||||||
SET HEADSEP | Set heading separator | ||||||||||||||||||||||||||||
SET LINESIZE | LINES | set linesize <size> | Set Table of Contents | |||||||||||||||||||||||||||
SET NEWPAGE|NEWP | set newpage <0|n|none> | Sets number of blank lines to print from the page top to the top title If newpage is set to 0, form feed character is printed at the beginning of each page | |||||||||||||||||||||||||||
SET MARKUP HTML | SET MARK HTML | SET MARK[UP] HTML [ON | OFF] [HEAD text] [BODY text] [TABLE text] [ENTMAP {ON | OFF}] [SPOOL {ON | OFF}] [PRE[FORMAT] {ON | OFF}] | Set output to HTML HTML [ON|OFF] HTML is a mandatory argument which specifies that HTML output is to be generated. HTML arguments, ON and OFF, specify whether or not to generate HTML output. The default is OFF. HEAD text The HEAD text option enables to specify content for the <HEAD> tag. By default, text includes a default in-line CSS and title. If text includes spaces, it must be enclosed in quotes. BODY text The BODY text option enables to specify attributes for the <BODY> tag. By default, there are no attributes. If text includes spaces, it must be enclosed in quotes. TABLE text The TABLE text option enables to enter attributes for the <TABLE> tag. By default, the <TABLE> WIDTH attribute is set to 90% and the BORDER attribute is set to 1. If text includes spaces, it must be enclosed in quotes. ENTMAP {ON|OFF} ENTMAP ON or OFF specifies whether or not SQL*Plus replaces special characters <, >, ” and & with the HTML entities <, >, " and & respectively. ENTMAP is set ON by default. SPOOL {ON|OFF} SPOOL ON or OFF specifies whether or not SQLS*Plus writes the HTML opening tags, <HTML> and <BODY>, and the closing tags, </BODY> and </HTML>, to the start and end of each file created by the SQLS*Plus SPOOL filename command. The default is OFF. Header and footer tags enabled by the SET MARKUP HTML SPOOL ON option are not written to the spool file until “SPOOL filename” command is not issued PRE[FORMAT] {ON|OFF} PREFORMAT ON or OFF specifies whether or not SQLS*Plus writes output to the <PRE> tag or to an HTML table. The default is OFF, so output is written to a HTML table by default. | |||||||||||||||||||||||||||
SET OUTPUT | set output <csv | json | default> | Set output to CSV (commas separated values), to JSON or to default output. Supported CSV and JSON format outputs all fields surrounded by double quotes | |||||||||||||||||||||||||||
SET PAGESIZE | PAGES | set pagesize <size> | Set output page size | |||||||||||||||||||||||||||
SET SQLPROMPT| SQLP | set sqlprompt <message> | reset | Sets the SQLS*Plus command prompt. SET SQLPROMPT can use define variables in the message | |||||||||||||||||||||||||||
SET TERMOUT|TERM | set termout on|off | Controls the display of output generated by commands in a script that is executed with @, @@ or START. OFF stops output to screen to enable output to a file without displaying it on a screen. ON displays the output on screen. TERMOUT OFF does not affect output from commands entered interactively or directed to SQLS*Plus from the OS. | |||||||||||||||||||||||||||
SET UNDERLINE | SET UND[ERLINE] {‘-‘ | c | ON | OFF} | Set the character to underline column headings. The underline character cannot be an alphanumeric or a white space. ON or OFF turns underlining on or off. | |||||||||||||||||||||||||||
SET VERIFY | Print ampersand replacing | ||||||||||||||||||||||||||||
SET VOUT | set vout on|off | Set vertical output mode | |||||||||||||||||||||||||||
SETVAR | SETVAR <variable> <value> | Set value of bind variable | |||||||||||||||||||||||||||
SHO[W] | SHOW <set parameter name> | Show value of the named SET parameter | |||||||||||||||||||||||||||
SHOW DB|DATABASE | Show current database | ||||||||||||||||||||||||||||
SHOW DBS|DATABASES | Show available databases | ||||||||||||||||||||||||||||
SHOW ERRORS | Show SQL Server error log | ||||||||||||||||||||||||||||
SHOW LICENSE | Show license information and license days to expiration | ||||||||||||||||||||||||||||
SHOW PARAMETER|PARM | show parameter <pattern> | Show database parameters | |||||||||||||||||||||||||||
SHOW SERVERS | Show names of SQL Server instances located on a servers that broadcast on local domain network | ||||||||||||||||||||||||||||
SHOW TABLES|TAB | Show database tables | ||||||||||||||||||||||||||||
SHOW USER | Show the current username | ||||||||||||||||||||||||||||
SPOOL | SPO[OL] [file_name[.ext] [CRE[ATE] | REP[LACE] | APP[END]] | OFF |] | Write output to file APPEND – add output to the file CREATE – would not allow to overwrite existing file REPLACE (default) – replace existing file OFF – stop spooling | |||||||||||||||||||||||||||
START | @ | Execute sql script | ||||||||||||||||||||||||||||
STARTREL | @@ | Execute sql script relative / nested to a running script | ||||||||||||||||||||||||||||
TTITLE | Syntax TTI[TLE] [printspec [text | variable] …] [ON | OFF] where printspec represents one or more of the following clauses used to place and format the text: CE[NTER] LE[FT] R[IGHT] S[KIP] [n] COL [n] TAB [n] Options: These options also apply to the BTITLE command. text The ttitle text. Enter text in single quotes if you want to place more than one word on a single line. variable A substitution variable or any of the following system- To print one of these values, reference the appropriate variable in the title. You can format variable with the FORMAT clause. SQLS*Plus substitution variables (& variables) are OFF Turns the ttitle off (suppresses its display) without affecting its definition. ON Turns the title on (restores its display). When you S[KIP] [n], n>=1 Skips to the start of a new line n times; if you omit n, COL [N] Moves to the line column n. N can be negative. TAB [n] Moves forward n columns (line columns, not database LE[FT] | CE[NTER] | R[IGHT] Left-align, center, and right-align data on the current TTITLE with no clauses lists current TTITLE definition. Examples To define “Monthly Report” as the top title and to left-
| Places and formats a specified title at the top of each report page. Enter TTITLE with no clauses to list its current definition. | |||||||||||||||||||||||||||
TSQL | Display t-sql procedure code | ||||||||||||||||||||||||||||
VARIABLE | VARIABLE <name> <type> -s <value> | declare a bind variable |
Download SQLS*Plus manual in PDF format
MORE NEWS
PreambleNoSql is not a replacement for SQL databases but is a valid alternative for many situations where standard SQL is not the best approach for...
PreambleMongoDB Conditional operators specify a condition to which the value of the document field shall correspond.Comparison Query Operators $eq...
5 Database management trends impacting database administrationIn the realm of database management systems, moreover half (52%) of your competitors feel...
The data type is defined as the type of data that any column or variable can store in MS SQL Server. What is the data type? When you create any table or...
PreambleMS SQL Server is a client-server architecture. MS SQL Server process starts with the client application sending a query.SQL Server accepts,...
First the basics: what is the master/slave?One database server (“master”) responds and can do anything. A lot of other database servers store copies of all...
PreambleAtom Hopper (based on Apache Abdera) for those who may not know is an open-source project sponsored by Rackspace. Today we will figure out how to...
PreambleMongoDB recently introduced its new aggregation structure. This structure provides a simpler solution for calculating aggregated values rather...
FlexibilityOne of the most advertised features of MongoDB is its flexibility. Flexibility, however, is a double-edged sword. More flexibility means more...
PreambleSQLShell is a cross-platform command-line tool for SQL, similar to psql for PostgreSQL or MySQL command-line tool for MySQL.Why use it?If you...
PreambleWriting an application on top of the framework on top of the driver on top of the database is a bit like a game on the phone: you say “insert...
PreambleOracle Coherence is a distributed cache that is functionally comparable with Memcached. In addition to the basic function of the API cache, it...
PreambleIBM pureXML, a proprietary XML database built on a relational mechanism (designed for puns) that offers both relational ( SQL / XML ) and...
What is PostgreSQL array? In PostgreSQL we can define a column as an array of valid data types. The data type can be built-in, custom or enumerated....
PreambleIf you are a Linux sysadmin or developer, there comes a time when you need to manage an Oracle database that can work in your environment.In this...
PreambleStarting with Microsoft SQL Server 2008, by default, the group of local administrators is no longer added to SQL Server administrators during the...