Pseudo-Columns for Oracle databases

Source: Internet
Author: User

Pseudo- column: a pseudo-column in Oracle is like a table column (a column in a table), but it is not stored in a table, a pseudo-column can be queried from a table, but its values cannot be inserted, updated, or deleted

Common pseudo-Columns are ROWID and rownum.

use of ROWID--quickly delete duplicate records

Parse: ROWID is the detailed address of the data, through ROWID,Oracle can quickly locate the location of the specific data of a row.

ROWID can be divided into two kinds of physical ROWID and logic ROWID .

in a normal table. rowID is a physical rowID , index Organization table (IOT) of the rowID is logical rowID .

When there is a large amount of duplicate data in the table, you can use ROWID quickly delete duplicate records.

Query statement:

Select Rowid,rownum from Student

ROWNUM

ROWNUM is the ordinal of the row in the result set returned by the query, which you can use to limit the number of rows returned by the query

through testing, Rownum can only filter =1 and <n , if >m cannot filter, how to evade.

construct a temporary table from a subquery so that the pseudo-column Rownun is called a column in a staging table, and then a qualified condition uses a pseudo-column

Alias.

Using pseudo-Columns to query for data with pseudo-column numbers equal to 2

Select *from

(

Select Id,name,rownum rn from student

) Temp

where RN =2

Querying 第4-6条 data with pseudo-columns

Select *from

(

Select Temp.*,rownum rn from

(

Select *from Student

) Temp

where rownum<=6

) Where rn>=4

Pseudo-Columns for Oracle databases

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.