12.07.2015 Views

Oracle SQL Developer

Oracle SQL Developer

Oracle SQL Developer

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using Pseudocolumns, Sequences, and <strong>SQL</strong> Functions6.5 Using Pseudocolumns, Sequences, and <strong>SQL</strong> FunctionsWith <strong>SQL</strong> built-in functions you can manipulate character, numeric, and date data in<strong>SQL</strong> statements. You can also perform operations on a collection of data with theaggregate functions.Pseudocolumns are built-in values that provide specific information with a query andare similar to functions without arguments. However, functions without argumentstypically return the same value for every row in the result set, whereaspseudocolumns typically return a different value for each row.This topic includes the following topics:■ Using Pseudocolumns With <strong>SQL</strong>■ Using Sequences■ Using Character Functions■ Using Arithmetic Operators■ Using Numeric Functions■ Using Date Functions■ Using Aggregate FunctionsSee Also:■<strong>Oracle</strong> Database <strong>SQL</strong> Reference for detailed information on <strong>SQL</strong>functions.6.5.1 Using Pseudocolumns With <strong>SQL</strong>A pseudocolumns is similar to a table column, but is not actually stored in a table. Apseudocolumn returns a value so it is similar to a function without argument. <strong>Oracle</strong>Database provides several pseudocolumns, such as the ROWNUM, SYSDATE, and USER.The ROWNUM pseudocolumn returns a number indicating the order in which <strong>Oracle</strong>selects the row in a query. SYSDATE returns the current date and time set for theoperating system on which the database resides. USER returns the name of the username that is currently logged in.Example 6–13 show the use of the ROWNUM, SYSDATE, and USER pseudocolumns. Notethe use of the table DUAL, which is automatically created by <strong>Oracle</strong> Database for use asa dummy table in <strong>SQL</strong> statements.Example 6–13 Using Pseudocolumns-- the following statement displays the SYSDATE, which is the current system date-- NOW is a column alias for display purposes-- DUAL is a dummy table with one row simply used to complete the SELECT statementSELECT SYSDATE "NOW" FROM DUAL;-- display the name of the current user, the user name should be HRSELECT USER FROM DUAL;-- using ROWNUM < 10 limits the number of rows returned to less than 10SELECT employee_id, hire_date, SYSDATE FROM employees WHERE ROWNUM < 10;See Example 6–18 on page 6-14 for another example of the use of SYSDATE.6-10 <strong>SQL</strong> <strong>Developer</strong> Online Help

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!