SQL*Plus Getting Started
Release 9.0.1 for Windows

Part Number A88829-01

Home

Book List

Contents

Index

Master Index

Feedback

Go to previous page Go to next page

3
Using SQL*Plus

This chapter explains how to start and use SQL*Plus from both the command line interface and the graphical user interface, and describes the graphical user interface menu options.

Specific topics discussed are:

Using the Command Line Interface

The SQL*Plus command line interface is standard on all operating systems.

If you are connecting to a remote Oracle database, make sure your Oracle Net/networking software is installed and working properly. For more information, see the Oracle9i Net Services Administrator's Guide and the Oracle9i Database Administrator's Guide for Windows.

To start the SQL*Plus command line interface:

  1. Select Command Prompt from Programs in the Start menu. A Command Prompt window appears.


    Text description of prompt.gif follows.
    Text description of the illustration prompt.gif

  2. Start SQL*Plus by entering

    C:\> SQLPLUS
    

    You can optionally include your login username and password separated by a slash (/), and a remote database name to connect to, for example:

    C:\> SQLPLUS username/password@connect_identifier
    

    Otherwise you will be prompted to enter your username and password.

Interpreting Arguments in Windows

The rules for interpreting arguments in Windows commands are:

Example

The following SET MARKUP command illustrates white space to separate arguments, the single string argument for HEAD surrounded by single quotes, and the escaped double quotes around Employees so that the characters are printed and not interpreted as string delimiters.

SET MARKUP HTML HEAD '<TITLE>Annual Report \"Employees\"</TITLE>'

For more information about SQL*Plus command line arguments, refer to the SQL*Plus User's Guide and Reference.

Changing the Command Line Font and Font Size

You can use the Windows Command Prompt Properties dialog to set the font and font size used in the SQL*Plus command line interface.

To Change the Command Line Interface Font and Font Size

  1. Right click in the command line interface title bar.

  2. Click Properties. The Window Preview box displays the current window's relative size on your monitor based on your font and font size selections. The Selected Font: box displays a sample of the current font.

  3. Click the Font tab.

  4. Select the font size to use from the Size box. Raster font sizes are shown as width by height in pixels. TrueType font sizes are shown as height in pixels.

  5. Select the font to use from the Font box.

  6. Select the Bold Fonts check box if you want to use a bold version of the font.

For more information about changing Windows Command Prompt properties, see Windows Help or click Help in the Command Prompt Properties dialog. For information about changing font face and size in the Windows Graphical User Interface (GUI), see "Changing the GUI Font and Font Size" later in this chapter.

Using a Special Character

To check if a font contains a particular character, for example, the Euro sign, enter the character's decimal number equivalent in the SQL*Plus command line interface. For example, the decimal number equivalent for the Euro sign is 128, so you would enter Alt+0128 to display it. If it appears correctly, the chosen font contains the Euro sign, otherwise you need to try another font.

You can use the Windows Character Map utility to view the characters available in a font. Character Map also shows the decimal number equivalent for extended ASCII characters. You access the Character Map utility by selecting Start, Programs, Accessories and then clicking Character Map.

Using the Graphical User Interface

While the command line interface is a standard feature of SQL*Plus on all operating system platforms, the graphical user interface is a feature of SQL*Plus for Windows.

If you are connecting to a remote Oracle database, make sure your Oracle Net/networking software is installed and working properly. For more information, see the Oracle9i Net Services Administrator's Guide and the Oracle9i Database Administrator's Guide for Windows.

The graphical user interface can be started from the Windows menus, or from a Windows command prompt.

Starting the GUI from the Windows Menu

  1. Select Programs in the Start menu. Then select Oracle - ORACLE_HOME, then Application Development, and click SQL Plus.

    The SQL*Plus window appears displaying the Log On dialog.


    Text description of logon.gif follows.
    Text description of the illustration logon.gif

    Enter a valid user name and password. If you are connecting to a remote Oracle database, enter the Oracle Net connect_identifier in the Host String field. See the Oracle9i Net Services Administrator's Guide for more information about configuring and using Oracle Net connect_identifiers.

  2. Click OK.

Starting the GUI from the Windows Command Prompt

  1. Select Command Prompt in the Start menu. A Command Prompt window appears.

  2. Enter

    C:\> SQLPLUSW
    

    The SQL*Plus graphical user interface starts. You can optionally include your login username and password separated by a slash (/), and a remote database name to connect to, for example:

    C:\> SQLPLUSW username/password@connect_identifier
    

    Otherwise enter the required information in the login dialog as described above. The Oracle SQL*Plus application window appears.


    Text description of 34.gif follows.
    Text description of the illustration 34.gif

Using the SQL*Plus Application Window

SQL*Plus displays the SQL command prompt in the application window.

To enter SQL and SQL*Plus commands, type each command at the SQL*Plus command prompt and press Enter.

Using the Mouse Buttons to Copy Text to the Command Prompt

You can use the mouse buttons to copy text from anywhere in the SQL*Plus interface to the SQL*Plus prompt in the same interface.

To copy text, select the text by clicking and dragging with the left mouse button. While still holding down the left mouse button, click the right mouse button. SQL*Plus copies the selected text to the SQL*Plus prompt.

Using the Command Keys

The following command keys have special functions in SQL*Plus:

Key  Function 

Home 

Top of screen buffer  

End 

Bottom of screen buffer 

Page Up 

Previous screen page 

Page Down 

Next screen page 

Ctrl+Page Up 

Show page on left of current screen page 

Ctrl+Page Down 

Show page on right of current screen page 

Alt+F3 

Find 

F3 

Find next 

Ctrl+C 

Cancels an operation running in SQL*Plus. 

Ctrl+C 

Copies text - when no operations are running in SQL*Plus. 

Ctrl+V 

Paste text  

Shift+Del 

Clear the screen and the screen buffer  

:

Using the SQL*Plus Menus

This section describes menus in the SQL*Plus graphical user interface (GUI). Bracketed entries show keyboard shortcuts to that File Menu command. The rightmost column shows the equivalent command line interface command where applicable.

File Menu

The File menu has the following options:

Option  Description of File Menu Option   Command Line 

Open 

The Open option retrieves a previously stored command file.

If you supply no file extension, SQL*Plus looks for command files with the .SQL extension. The command file should contain a single SQL or PL/SQL statement. It should not contain multiple statements or SQL*Plus commands. 

GET filename 

Save 

The Save option has three alternatives: Save Create, Save Replace, and Save Append

SAVE 

 

  • Save Create saves the contents of the SQL*Plus buffer in a command file. By default, SQL*Plus assigns the .SQL extension to command files. You can specify a different extension in the File name text box.

  • Save Replace replaces the contents of an existing file with the contents of the SQL*Plus buffer. SQL*Plus creates the file if it does not exist.

  • Save Append adds the contents of the SQL*Plus buffer to the end of the file you specify.

 

SAVE filename CREATE

SAVE filename REPLACE

SAVE filename APPEND 

 

After you save a command file, you can:

  • Retrieve the file using the Open option on the File menu.

  • Edit the file using the Editor option on the Edit menu.

  • Run the file using the START or RUN commands from the SQL*Plus command prompt.

 

 

Save As 

The Save As option saves the contents of the SQL*Plus buffer in a command file.

By default, SQL*Plus assigns the .SQL extension to command files. You can specify a different extension in the File name text box. 

SAVE filename 

Spool 

The Spool option has two alternatives: Spool File and Spool Off. SQL*Plus for Windows does not support the SPOOL OUT clause. 

 

 

  • Spool File stores query results in a file. By default, SQL*Plus assigns the .LST extension to spool files. You can specify a different extension in the File name text box. You can edit the results with the Editor option on the Edit menu, and print the file from a Windows text editor.

  • Spool Off turns off spooling.

 

SPOOL filename


SPOOL OFF 

Run 

The Run option lists and executes the SQL command or PL/SQL block currently stored in the SQL buffer. 

RUN 

Cancel
(Ctrl+C) 

The Cancel option cancels an in-progress operation.

The Cancel keyboard shortcut is only available when a SQL*Plus operation is running in the SQL*Plus session. When no SQL*Plus operation is running, Ctrl+C copies selected text. 

Ctrl-C 

Exit 

The Exit option commits all pending database changes and closes the SQL*Plus application window. 

EXIT 

Edit Menu

The Edit menu has the following options:

Option  Description of Edit Menu Option  Command Line 

Copy
(Ctrl+C) 

The Copy option copies selected text to the Clipboard.

After you copy text to the Clipboard, you can paste the text into other Windows applications, such as Microsoft Excel and Microsoft Word.

The Copy keyboard shortcut is only available when no SQL*Plus operations are running in the SQL*Plus session. When a SQL*Plus operation is running, Ctrl+C cancels the running operation. 

not applicable 

Paste
(Ctrl+V) 

The Paste option pastes the contents of the Clipboard to the SQL*Plus command line.

Note: A maximum of 3625 characters can be pasted from the Clipboard to the SQL*Plus command line during a single paste operation. 

not applicable 

Clear
(Shift+Del) 

The Clear option clears the screen buffer and the screen of the SQL*Plus application window. 

CLEAR SCREEN 

Editor 

The Editor option has two alternatives: Invoke Editor and Define Editor

 

 

  • Invoke Editor loads the contents of the SQL*Plus buffer into an editor. By default, SQL*Plus saves the file to AFIEDT.BUF. You can specify a different file name in the editor.

  • Define Editor defines the editor that is invoked.

 

EDIT



DEFINE_EDITOR
= editor name 

Search Menu

The Search menu has the following options:

Option  Description of Search Menu Option  Command Line 
Find
(Alt+F3) 

The Find option searches for a character, a word, or a group of characters or words in the SQL*Plus application window. Find begins the search at the top of the displayed screen.

Note: When Find reaches the end of the displayed screen, it does not wrap and continue searching from the top of the screen buffer. 

not applicable 

Find Next
(F3) 

The Find Next option finds the next occurrence of the search text. 

not applicable 

Options Menu

The Options menu has the following options:

Option  Description of Options Menu Option  Command Line 

Environment 

The Environment option allows you to set system variables to alter the SQL*Plus environment for your current session. This dialog has three areas: Set Options, Value, and Screen Buffer.

Note: See "Setting Options and Values Using the Environment Dialog" for examples of how these controls interact. 

 

 

Set Options

This area has a list of variables you can select to establish aspects of the SQL*Plus environment for your current session, such as:

  • Setting the display width for NUMBER data.

  • Setting the display width for LONG data.

  • Enabling or disabling the printing of column headings.

  • Setting the number of lines per page.

See the "Command Reference" chapter in the SQL*Plus User's Guide and Reference for descriptions of each system variable in the SET command. 

SET variable value 

 

Value

The Value area has four options: Default, Custom, On, and Off.

Note: When Custom is selected, the On and Off buttons and the text field may or may not be enabled for user selection. The availability of these fields depends on the item selected in the Set Option.  

SET variable value 

 

Screen Buffer

This area has two text boxes: Buffer Width and Buffer Length

SET variable value 

 

  • In the Buffer Width text box, you set the number of characters that SQL*Plus displays on one line. If you enter a number smaller than the length of output data, SQL*Plus truncates the data to match the buffer width you specified. The default value of the Buffer Width parameter is 100 characters. You can specify from 80 to 1000 characters on one line.

  • In the Buffer Length text box, you set the number of lines that SQL*Plus displays on the screen. If SQL*Plus displays more lines of data than you specify, the remaining lines of data will "wrap around" to the top of the screen buffer. The default value of the Buffer Length parameter is 1000 lines. You can specify from 100 to 2000 lines on one screen.

 

 

 

Notes: When you change the Screen Buffer option, SQL*Plus displays a dialog to alert you that if you shorten the size of your screen buffer, some data may not be displayed on your screen. Click OK to proceed. 

 

 

If you use SET MARKUP to send output to a HTML table, the number of lines specified in the Buffer Length variable specifies the number of HTML table rows. Each HTML table row may contain more than one text line. 

 

Help Menu

The Help menu has the following option:

Option  Description of Help Menu Option  Command Line 

About SQL*Plus 

Displays the SQL*Plus version number and copyright information.

You access SQL*Plus help from the SQL*Plus prompt. See "Accessing SQL*Plus Help" in Chapter 2

not applicable 

Setting Options and Values Using the Environment Dialog

Choose Environment from the Options menu to display the Environment dialog which you can use to create a SQL environment statement for the current session.

Choose an item from the Set Options list to begin. You can use the default settings, or you can customize the settings by using the other dialog controls. The available controls vary with the options you choose. You can make multiple changes to options and values. When the text box is available, you can enter appropriate text or appropriate numeric values. Click OK to commit your settings.


Note:

Options introduced after SQL*Plus Release 8.1.6 can only be accessed through the command line and are not available in the SQL*Plus for Windows Environment dialog. These options are:

SET MARKUP

SET SQLPLUSCOMPATIBILITY {ON|OFF}

See "Command Reference" in the SQL*Plus User's Guide and Reference for descriptions of these SET commands. 


Example 3-1

Example 3-2

Changing the GUI Font and Font Size

There are two registry entries that set the font and font size used in the SQL*Plus Windows GUI. SQLPLUS_FONT sets the font face, and SQLPLUS_FONT_SIZE sets the font size in pixels. You use the Windows Registry Editor to create these two registry entries and define values for them. Ensure that you create the correct entries in uppercase, and that the font names you enter are correct. If you enter an incorrect name, the default font Fixedsys, and size 16, are used.


Warning:

Microsoft does not recommend modifying the registry. Editing the registry may affect your operating system and software installation. Only advanced users should edit the registry. Oracle takes no responsibility for problems arising from editing the Windows registry.  


You can choose any fixed-pitch TrueType font available in your Windows system such as Courier New or Lucida Console. If you choose a proportional pitch font such as Arial or Times New Roman, or if you enter an unavailable font, the registry entry is ignored and the default font and size, Fixedsys 16, are used. If you choose an unavailable font size, the default font size, 16, is used.

If you do not create the SQLPLUS_FONT registry entry, or if you do not specify a value for SQLPLUS_FONT, the default font and size, Fixedsys 16, are used.

If you want to use particular characters, such as the Euro sign, you should make sure that the fixed pitch font you choose contains those characters.

To Change the Windows GUI Font and Font Size

  1. Select Run from the Start menu and then enter regedit in the Open field.

  2. Click OK to start the Registry Editor. The Registry Editor is displayed.

  3. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0.


    Note:

    If you have more than one Oracle installation, you must select the HOME entry associated with the Windows GUI you want to change. HOME0 is the registry entry for an Oracle installation. A subsequent Oracle installation will have the registry entry HOME1 and the next HOME2 and so on.

    Changes only affect a SQL*Plus Windows GUI started from the associated Oracle installation, so you can use different settings for each Oracle installation. 


  4. Click New String Value in the Edit menu. A new string value, with the default name, NewValue #1 is created at the bottom of the right pane of the Registry Editor. The default name of the new string value is selected ready for you to replace with the name you want.

  5. Enter SQLPLUS_FONT as the name of the new font face string value. If you miskey the name or inadvertently enter it in mixed or lower case, you can edit the name by selecting Rename from the Edit menu.

    or

    Enter SQLPLUS_FONT_SIZE as the name of the new font size string value. If you miskey the name or inadvertently enter it in mixed or lower case, you can edit the name by selecting Rename from the Edit menu.

  6. Click Modify from the Edit menu or press Enter again to display the Edit String dialog.

  7. Enter the font name you want to use, such as Courier New, in the Value Data: field. SQL*Plus will use the new font the next time you start the SQL*Plus Windows GUI.

    or

    Enter the font size you want to use in pixels, such as 14, in the Value Data: field. SQL*Plus will use the new font size the next time you start a SQL*Plus Windows GUI.


    Note:

    You should not change the font face or font size while any SQL*Plus Windows GUI is active. You should exit all SQL*Plus Windows GUI sessions, make font face and font size changes in the registry, exit the Registry Editor and then restart the SQL*Plus Windows GUI to see the changes.  


Using a Special Character

To check if a font contains a particular character such as the Euro sign, enter the character's decimal number equivalent in the SQL*Plus Windows GUI. For example, the decimal number equivalent for the Euro sign is 128, so you would enter Alt+0128 to display it. If it appears correctly, the chosen font contains the Euro sign, otherwise you need to try another font.

You can also use the Windows Character Map accessory to view the characters available in a font. Character Map also shows the decimal number equivalent for extended ASCII characters. You access the Character Map accessory by selecting Start, Programs, Accessories and then Character Map.

Exiting SQL*Plus

You enter EXIT or QUIT at the SQL*Plus prompt to exit SQL*Plus from the command line interface or from the GUI.

You return to the Windows Command Prompt when you exit either the command line interface, or the GUI if you started it from the command line with SQLPLUSW.

Click Exit from the File menu to exit from the GUI. The GUI closes and you return to Windows when you exit SQL*Plus from the GUI.


Go to previous page Go to next page
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.

Home

Book List

Contents

Index

Master Index

Feedback