Performing a SELECT Statement Using SQLPlus


Performing a SELECT Statement Using SQL*Plus

Once you re logged on to the database using SQL*Plus, try entering the following SELECT statement that returns the current date from the database:

 SELECT SYSDATE FROM dual; 

SYSDATE is a built-in Oracle function that returns the current date, and the dual table is a built-in table that contains a single row. You can use the dual table to perform simple queries whose results are not retrieved from a specific table.

Note  

SQL statements directly entered into SQL*Plus are terminated using a semicolon character (;).

Figure 1-3 shows the results of this SELECT statement in SQL*Plus running on Windows.

click to expand
Figure 1-3: Executing a SQL SELECT statement using SQL*Plus

As you can see from the previous figure, the result of the query displays the current date from the database.

You can edit your last SQL statement in SQL*Plus by entering EDIT . This is useful when you make a mistake or you want to make a change to your SQL statement. In Windows, when you enter EDIT you are taken to the Notepad application; you then use Notepad to edit your SQL statement. When you exit Notepad and save your statement, the statement is passed to SQL*Plus where you can re-execute it.

Note  

You ll learn more about editing SQL statements using SQL*Plus in Chapter 5.




Oracle Database 10g SQL
Oracle Database 10g SQL (Osborne ORACLE Press Series)
ISBN: 0072229810
EAN: 2147483647
Year: 2004
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net