Rownum - sql pseudocolumns, PL-SQL Programming

ROWNUM

The ROWNUM returns a number representing the order in which a row was selected from the table. The first row selected has a ROWNUM of 1; the second row has a ROWNUM of 2, and so on. If the SELECT statement involves an ORDER BY clause, then the ROWNUMs are assigned to the retrieved rows before the sort is complete.

You can use the ROWNUM in an UPDATE statement to assign exclusive values to each row in a table. You can also use ROWNUM in the WHERE clause of a SELECT statement to the limit the number of rows retrieved, as shown:

DECLARE

CURSOR c1 IS SELECT empno, sal FROM emp

WHERE sal > 2000 AND ROWNUM < 10; -- returns 10 rows

The value of ROWNUM increase only whenever a row is retrieved, so the only significant use of ROWNUM in a WHERE clause is

... WHERE ROWNUM < constant;

Posted Date: 10/4/2012 3:43:52 AM | Location : United States







Related Discussions:- Rownum - sql pseudocolumns, Assignment Help, Ask Question on Rownum - sql pseudocolumns, Get Answer, Expert's Help, Rownum - sql pseudocolumns Discussions

Write discussion on Rownum - sql pseudocolumns
Your posts are moderated
Related Questions
Using EXISTS The EXISTS(n) returns TRUE if the nth element in a collection exist. Or else, EXISTS(n) returns FALSE. Primarily, you use EXISTS with DELETE to maintain the spars

Example of Cast Operator So long as CAST is used as shown, we could obtain the total marks for each exam in similar fashion, using SUM (Mark) AS TotalMarks. However, this giv

Question: (a) In the context of database security explain how the following database features help to enforce security in the database system: (i) Authorisation (ii) Access


SQL Pseudocolumns The PL/SQL recognizes the following SQL pseudocolumns, that returns the specific data items: LEVEL, NEXTVAL, CURRVAL, ROWID, & ROWNUM. The Pseudocolumns are n

Using Cursor Attributes: Every cursor has 4 attributes: %NOTFOUND, %FOUND, %ISOPEN, and %ROWCOUNT. If appended to the cursor name, they return the helpful information about

Identifiers You use identifiers to name the PL/SQL program items and units that include constants, variables, cursors, exceptions, cursor variables, subprograms, and packages.

Using the Collection Methods The collection methods below help to generalize the code and make collections easier to use and also make your applications easier to maintain:

IF Statement The IF statement executes a series of statement conditionally. Whether the series is executed or not depends on the value of the Boolean expression. Syntax:

Semijoin and Composition - SQL For semijoin, the dyadic relational operator MATCHING, defined thus: r1 MATCHING r2, where r1 and r2 are relations such that r1 JOIN r2 is de