Thursday, 4 October 2012

Lesson -3 How to run SQL commands



The SQL command language enables you to manipulate data in the database. The syntax of the SQL query commands will  be discussed in next chapter. In this section we will discuss the logistics of SQL*Plus as it relates to SQL

The example below shows you how to enter a SQL command:

1.            SQL> SELECT EMPNO, ENAME, JOB, SAL

When you are done, press [RETURN key] to move to the next line.

  1. SQL*Plus will display a ``2'', the prompt for the second line.

3.            2    FROM EMP WHERE SAL > 35000;

The semicolon (;) means that this is the end of the command. Press [RETURN] and SQL*Plus will process the command and display the results on the screen. After displaying the results and the number of rows retrieved, SQL*PLus displays the command prompt again.

          SQL>

You can divide your SQL command into separate lines at any points you wish, as long as individual words are not split between lines.

You can end a SQL command in one of three ways:

  1. A semicolon(;) tells SQL*plus that you want to run the command. SQL*Plus will process the command and store it in the SQL buffer.
  2. A slash (/) on a line by itself also tells SQL*Plus that you wish to run the command. SQL*Plus will process the command and store it in the SQL buffer.
  3. A blank line tells SQL*Plus that you have finished entering the command, but do not want to run it yet. Press [RETURN] at the end of the last line of the command. SQL*Plus prompts you with another line number. Press [RETURN] again; SQL*Plus now prompts you with the SQL*Plus command prompt. SQL*Plus does not execute the command, but stores it in the SQL buffer. If you subsequently enter another SQL command and execute it using a semicolon (;) or a slash (/), SQL*Plus overwrites the unexecuted command in the buffer.

No comments:

Post a Comment