iSelfSchooling.com - Copyright © 1999-2009  References  |  Job Openings  | Login (Staff | Members)
    Home  | Search more...  | Community of Sharing Knowledge (with FREE Online Video Training)
    Oracle Syntax  | Suggestions  | Private Tutoring  | Member Collaboration  | Get Translations...

  Copyright & User Agreement

    Email2aFriend  | Homepage us! |  Bookmark

Services

 Vision/Mission

 Services

 Biography

 Contact Us

 

 FREE Training

 SQL

 PL/SQL

 Forms 

 Reports

 Other TOOLS

 Fundamentals

 Performance

 OEM

 Application Server

 Grid Control

 Articles

 Prepare for OCP

 

More to know...

Acknowledgement___

 Who is who

 University Directory

 Links...

 

 

 

 

More Resources by Google:

Topics:  Hands-On 05 - Command Line Editing

 

Here you will learn how to use command line editor which it is native to SQL*PLUS.

You will use the following command.

    "L" command - Lists SQL or PL/SQL from the SQL buffer

    "I" command - Inserts SQL or PL/SQL lines

    “Del” command - Deletes SQL or PL/SQL lines

    "C" command - Changes SQL or PL/SQL lines

    SAVE command

    GET command

 

 Manuscript

 

Go to MS-DOS and make a new directory to be used for your new scripts and programs.

 

Change directory to the root directory.

>>cd ..

 

Make a directory called "iself".

>> mkdir iself

 

Change the directory to the iself directory.

>> cd iself

 

List directory.  Notice that there is nothing in it.

>> dir

 

Login to “sqlplus” as "iself” password “schooling".

>> sqlplus iself/schooling

 

From now on the “iself” directory is a default directory for “SQLPLUS.”

 

Query the dept table.

>> select deptno, dname, loc from dept;

 

Always the last “sql” statement is in the Oracle buffer.

Type the letter "L" to list the last entered “SQL” statement.

>> l

 

The asterisk next to the line indicates the current line position.

 

Run the “SQL” statement in the buffer, using the "run" command.

>> run

 

or the letter "r."

>> r

 

or "/"

>> /

 

Write a format free “sql” statement to query the dept table; and enter each word in a line.

>>           select

        deptno,

        dname,

        loc

        from

        dept;

End the sql statement with “;” to terminate and execute the statement.

 

List the statement from the Oracle buffer.

>> L

 

Write a format free query and use a dot at the end of the sql statement to end the statement, but not run the statement..

The sql statement will be in the Oracle buffer as long as it was not replaced or the user session was not terminated.

>>          select

        deptno

        ,

        dname

        ,

        loc

        from

        dept

        .

 

Then run the statement.

>> r

 

Use the command line editor to add a column heading to the "loc" column.

Change the current line position to number 6 and then use the "C" or change command to add column heading.

>> L6

>> c/loc/loc "location"/

 

List the sql statement lines from 2 to 7.

>> L 2 7

 

List the entire query.

>> L

 

Delete the sql statement lines from 4 to 5.

>> del 4 5

 

Run the query.  Notice that the department name column was deleted.

>> /

 

Position line number 3 to the current line.

>> L3

 

Use the "i" or insert command to insert a line.

Then use the dot to terminate the insert mode.

>> i

4i dname,

.

 

List the query.  The line was added.

>> L

 

Then run the statement.

>> /

 

Save the sql statement as "d-e-p-t" file in the “iself” directory.

Notice that the default extension is “s-q-l.”

>> save dept

 

Use the "get" command to replace the sql file into the buffer.

>> get dept

 

Exit “sqlplus” to see where the file was stored?

>> exit

 

List the file names in the iself directory.

>> dir

 

Use the "type" command to list the query.

>> type dept.sql

 

Login to "sqlplus" as “iself/schooling”

>> sqlplus iself/schooling

List the buffer.

Notice that there is no query in the buffer.

Get the file and then run it.

 

>>l

 

>> get dept

          /

 

or use the "@" sign command to run the file.

>> @c:\iself\dept

 

Or use the "start" command to run the file.

>> start dept

 

These are different ways you can run the sql file.

 

Now, you should practice this over and over, until you become a master at it.

Good Luck!

 

 
 
Google
 
Web web site