SQL*Plus executables: sqlplusw (Windows only) sqlplus (UNIX and Windows) Logging in to SQL*Plus via windows, dos or unix SQL*Plus Windows shortcut Right click on icon to get Properties: target - this indicates the sqlplus exe you want to use C:\Oracle\Ora81\bin\SQLPLUSW.EXE you can extend the functionality of target by adding your username and database name C:\Oracle\Ora81\bin\SQLPLUSW.EXE username@mydatabase or adding name, password and database name(MAKE SURE YOUR PC IS SECURE AT ALL TIMES!!) C:\Oracle\Ora81\bin\SQLPLUSW.EXE password/username@mydatabase and you can even automatically call a script that resides in your 'start in' directory C:\Oracle\Ora81\bin\SQLPLUSW.EXE password/username@mydatabase @ulcase1.sql or you can automatically call a script by specifying the full path of the script C:\Oracle\Ora81\bin\SQLPLUSW.EXE password/username@mydatabase @c:\\ulcase1.sql start in - use to set your current directory where your scripts are stored You can also set up a shortcut key to invoke the shortcut, indicate if you want sqlplusw to run in a normal, full or minimized window with run and give a comment for mouse-over help. Also, you can change the text of the icon indicating the shortcut to help you remember how you set up the shortcut. Executing SQL A few examples: select select * from emp; insert insert into dept (deptno, dname, loc) values(80, 'IT', 'Boston'); update update dept set loc = 'Madison' where deptno = 80; delete delete dept where deptno = 80; commit commit; -- allows you to make your insert, update or delete changes permanent rollback rollback; -- allows you to undo your insert, update and delete statements since the last commit Sending output to a file (spooling to a file) log in to the database using SQL*Plus SQL> spool test.out SQL> select * from emp; SQL> spool off SQL> edit test.out Running SQL*Plus scripts (scripts can contain both SQL*Plus commands and SQL statements) Using the '@': SQL> @ulcase1.sql (script must be in your 'current' directory) or SQL> @c:\path\ulcase1.sql (indicate full path so your current directory doesn't matter or using the start command: SQL> start ulcase1.sql Each SQL statement in your script must end in a ';' or a '/'. A special 'script' called the buffer (seen on the OS as afiedt.buf) The buffer stores the last SQL statement that was executed. The buffer holds only SQL statements. Too see the contents of the buffer: SQL> edit or SQL> list To change the contents of the buffer: run a new SQL statement or SQL> edit or use sqlplus line mode edit commands - see page 46 and 47 of the SQL*Plus User Guide or attached printout of those pages. What's the deal with the '/'? The '/' is the sqlplus run command. The buffer needs to end in the '/' to run. The '/' can be used to re-execute the command in the buffer. The ';' is not allowed in the buffer but is allowed in any other sqlplus script. Try this: SQL> select * from emp; SQL> / The second line will run the statement in the buffer which is the last statement you ran. Comments -- single line or /* multiple line */ SQL*Plus commands vs SQL statements SQL*Plus commands are used to affect the SQL*Plus environment and are proprietary to SQL*Plus. SQL statements are used to affect the database or get information from the database and can be executed from any tool that supports SQL. SQL*Plus commands do not end in a ';' or '/'. Examples of SQL*Plus commands we have seen so far: @ / start list edit spool The save command will save the contents of the buffer to a file in the current directory: SQL> select * from emp; SQL> save test.sql This will save 'select * from emp' to the file test.sql Changing the behavior of your SQL*Plus session using the SQL*Plus command set: set linesize 500 set echo on set echo off set pagesize 80 There are many more set options. These can be seen either in the documentation or in sqlplusw from the menu Options|Environment. The show command allows you to see who what user id you are using: SQL> show user The column command can be useful for formatting results from a query (select statement): SQL> column format a10 this formats any column with for a heading as an alpha-numeric width of 10. SQL> column format $99,999.99 this formats any column with for a heading as currency. The describe command allows you to see the structure of a table: SQL> desc emp Name Null? Type ----------------------------- -------- -------------------- EMPNO NOT NULL NUMBER(4) ENAME CHAR(10) JOB CHAR(9) MGR NUMBER(4) HIREDATE DATE SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2) The exit command allows you to end your SQL*Plus session. It also can be embedded in a script to automatically exit SQL*Plus at the end of the script.