Hello Friends ,
Lots of My dear friends and viewers have requested to know about ROWID and its Its details .
This Post I try to give more details about Rowid and How best can we use it to locate the unique Record
Rowid is also called as Pseudo Column .
With Help of ROWID , We can delete the duplicate records as well as an example
DELETE FROM XXGH WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM XXGH GROUP BY EMPNO);
Lots of My dear friends and viewers have requested to know about ROWID and its Its details .
This Post I try to give more details about Rowid and How best can we use it to locate the unique Record
Rowid is also called as Pseudo Column .
For each row in the database, the ROWID
pseudo ccolumn returns the address of the row. Oracle Database rowid values
contain information necessary to locate a row:
• The
data object number of the object
• The
data block in the datafile in which the row resides
• The
position of the row in the data block (first row is 0)
• The
datafile in which the row resides (first file is 1). The file number is
relative to the tablespace.
Usually, a rowid value uniquely
identifies a row in the database. However, rows in different tables that are stored together in the same
cluster can have the same rowid.
Values of the ROWID pseudocolumn have
the datatype ROWID or UROWID. Please refer to "ROWID Datatype" and
"UROWID Datatype" for more information.
Rowid values have several important
uses:
• They
are the fastest way to access a single row.
• They
can show you how the rows in a table are stored.
• They
are unique identifiers for rows in a table.
You should not use ROWID as the primary
key of a table. If you delete and reinsert a row with the Import and Export
utilities, for example, then its rowid may change. If you delete a row, then
Oracle may reassign its rowid to a new row inserted later.
Although you can use the ROWID
pseudo column in the SELECT and WHERE clause of a query, these pseudo column
values are not actually stored in the database. You cannot insert, update, or
delete a value of the ROWID pseudo column.
Example This statement selects the
address of all rows that contain data for employees in department 20:
SELECT ROWID, last_name
FROM XXGHAN
WHERE department_id = 50;
With Help of ROWID , We can delete the duplicate records as well as an example
DELETE FROM XXGH WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM XXGH GROUP BY EMPNO);
Comments
Post a Comment