If you want to see the current values of SQL*Plus system settings, you can use t
he SHOW command as shown in the following tutorial exercise:
SQL> SHOW AUTOCOMMIT autocommit OFF SQL> SHOW HEADING heading ON SQL> SHOW LINESIZE linesize 80 SQL> SHOW PAGESIZE pagesize 14 SQL> SHOW FEEDBACK FEEDBACK ON for 6 or more rows SQL> SHOW TIMING timing OFF SQL> SHOW NULL null "" SQL> SHOW ALL appinfo is OFF and set to "SQL*Plus" arraysize 15 autocommit OFF autoprint OFF autorecovery OFF autotrace OFF blockterminator "." (hex 2e) cmdsep OFF colsep " " compatibility version NATIVE concat "." (hex 2e) copycommit 0 COPYTYPECHECK is ON define "&" (hex 26) describe DEPTH 1 LINENUM OFF INDENT ON echo OFF ... What Are SQL*Plus Environment Variables? Behaviors of SQL*Plus are also controlled a some environment variables predefine d on the local operating system. Here are some commonly used SQL*Plus environmen t variables: ORACLE_HOME - The home directory where your Oracle client application is install ed. PATH - A list of directories where SQL*Plus will search for executable or DLL fi les. PATH should include $ORACLE_HOME\bin. SQLPLUS - The directory where localization messages are stored. SQLPLUS should b e set to $ORACLE_HOME\sqlplus\mesg TNS_ADMIN - The directory where the connect identifier file, tnsnames.ora is loc ated. TNS_ADMIN should be set to $ORACLE_HOME/network/admin. How To Generate Query Output in HTML Format? If you want your query output to be generated in HTML format, you can use the "S ET MARKUP HTML ON" to turn on the HTML feature. The following tutorial exercise gives you a good example: SQL> connect HR/retneciyf SQL> SET MARKUP HTML ON SQL> SELECT FIRST_NAME, LAST_NAME, HIRE_DATE <br> 2 FROM EMPLOYEES WHERE FIRST_NAME LIKE 'Joh%'; <br> <p> <table border='1' width='90%' align='center' summary='Script output'> <tr> <th scope="col"> FIRST_NAME </th> <th scope="col"> LAST_NAME </th> <th scope="col"> HIRE_DATE </th> </tr> <tr> <td> John </td> <td> Seo </td> <td> 12-FEB-98 </td> </tr> <tr> <td> John </td> <td> Russell </td> <td> 01-OCT-96 </td> </tr> </table> <p> What Is Output Spooling in SQL*Plus? The output spooling a nice feature of the command-line SQL*Plus tool. If the spo oling feature is turned on, SQL*Plus will send a carbon copy of the everything o n your screen to a specified local file. Output spooling is used mostly for quick dump of data to local files. Here are t he commands to turn on and off output spooling in SQL*Plus: SPOOL fileName - Turning on output spooling with the specified file. SPOOL OFF - Turning off output spooling and close the spool file. How To Save Query Output to a Local File? Normally, when you run a SELECT statement in SQL*Plus, the output will be displa yed on your screen. If you want the output to be saved to local file, you can us e the "SPOOL fileName" command to specify a local file and start the spooling fe ature. When you are done with your SELECT statement, you need to close the spool file with the "SPOOL OFF" command. The following tutorial exercise gives you a good example: SQL> connect HR/retneciyf SQL> SET HEADING OFF SQL> SET FEEDBACK OFF SQL> SET LINESIZE 1000 SQL> SPOOL \temp\employees.lst SQL> SELECT * FROM EMPLOYEES; ...... SQL> SPOOL OFF You should get all records in employees.lst with fixed length fields. What Is Input Buffer in SQL*Plus? Input buffer is a nice feature of the command-line SQL*Plus tool. It allows you to revise a multiple-line command and re-run it with a couple of simple commands . By default, input buffer is always turned on in SQL*Plus. The last SQL stateme nt is always stored in the buffer. All you need is to remember to following comm only used commands: LIST - Displays the SQL statement (the last executed SQL statement) in the buffe r. RUN - Runs the SQL statement in the buffer again. ";" is a quick command equival ent to RUN. CLEAR BUFFER - Removes the SQL statement in the buffer. INPUT line - Adds a new line into the buffer. APPEND text - Appends more text to the last line in the buffer. DEL - Deletes one line from the buffer. CHANGE /old/new - Replaces 'old' text with 'new' text in the buffer. How To Revise and Re-Run the Last SQL Command? If executed a long SQL statement, found a mistake in the statement, and you don' t want enter that long statement again, you can use the input buffer commands to the correct last statement and re-run it. The following tutorial exercise gives you a good example: SQL> connect HR/retneciyf SQL> SELECT FIRST_NAME, LAST_NAME, HIRE_DATE 2 FROM EMPLOYEE WHERE FIRST_NAME LIKE 'Joh%'; FROM EMPLOYEE WHERE FIRST_NAME LIKE 'Joh%' * ERROR at line 2: ORA-00942: table or view does not exist SQL> LIST 1 SELECT FIRST_NAME, LAST_NAME, HIRE_DATE 2* FROM EMPLOYEES WHERE FIRST_NAME LIKE 'Joh%' SQL> CHANGE /EMPLOYEE/EMPLOYEES/ 2* FROM EMPLOYEES WHERE FIRST_NAME LIKE 'Joh%' SQL> RUN (Query output) SQL> INPUT ORDER BY FIRE_DATE SQL> LIST 1 SELECT FIRST_NAME, LAST_NAME, HIRE_DATE 2 FROM EMPLOYEE WHERE FIRST_NAME LIKE 'Joh%' 3* ORDER BY HIRE_DATE SQL> RUN (Query output) SQL> CLEAR BUFFER buffer cleared SQL> LIST SP2-0223: No lines in SQL buffer.