An invalid Oracle ROWID is a row address that no longer points to a real row in the table you're querying. You usually find it in three ways: fetch it from stale client data or a stored reference and watch the query fail, scan the table and compare returned ROWIDs against what was stored, or validate it explicitly with DBMS_ROWID.ROWID_VERIFY. The first condition is always the same — the ROWID string itself must be structurally valid before you can even test it against a table, and the target table must still exist in the same form.
When a row is deleted and its block reused, the physical address encoded in a ROWID can survive in an application table, a queue, or a log while pointing to a different row or to nothing at all. The trick isn't writing a clever query; it's recognizing that "invalid" has a few distinct meanings in Oracle, and each one needs a different check.
What "Invalid" Actually Means for an Oracle ROWID
Oracle recognizes two ROWID families, and they fail differently.
An extended ROWID is the 18-character base-64 string (for example, AAAPeZAAEAAAAJwAAA) stored in every heap table. It encodes four pieces: the data object number, the relative file number, the block number, and the row number within the block. Because the data object number is embedded, an extended ROWID from one table generally won't validate against another table — that mismatch alone is a useful test.
A restricted ROWID is the older format, typically eight characters representing file, block, and row. It's still used internally for things like index-organized tables and some fixed tables, but your application data almost never stores it. Check with DBMS_ROWID.ROWID_TYPE if you're unsure which one you have.
"Invalid" then splits into three practical cases:
1: Malformed — the string isn't a legal ROWID at all (wrong length, illegal characters, truncated during a copy). 2: Structurally valid but stale — the string parses and encodes a real file and block, but the row number no longer exists or the block now belongs to a different object. 3: Mismatched — the ROWID is valid but belongs to a different table than the one you're testing against.
Each case needs a different tool. Reaching for the wrong one is where people waste hours.
Prerequisites Before You Start
Gather these before touching SQL:
The exact ROWID strings you suspect, plus where they came from (a staging table, an error log, a client cache). The table name and, ideally, its object ID, because the object ID is what extended ROWIDs are tied to. Access to the table with permission to run DBMS_ROWID functions or read DUMP(ROWID). A test window or a read-only replica, since full-table scans on large tables are expensive and you don't want to lock anything.
If you have only a raw string from a log with no table name, the object number encoded inside an extended ROWID can help you infer the source table via DBA_OBJECTS. That's often the fastest way back to context.
Method 1: Validate the String With DBMS_ROWID.ROWID_VERIFY
This is the cleanest first check because it answers "does this ROWID point to a row in this table right now?" The function returns an integer, and the codes are the whole story:
0 — valid ROWID referencing an existing row in the specified table. 1 — valid ROWID but the object number doesn't match the table (wrong table). 2 — valid ROWID but the row doesn't exist (deleted or never there). 3 — valid ROWID but the row is locked or being modified in a way Oracle can't confirm. 4 — the ROWID is not valid for any reason (often malformed input).
A minimal call looks like this in plain form:
Expect 0 for good rows and 2 or 4 for the ones you're hunting. Anything other than 0 deserves a follow-up, and 2 versus 4 tells you whether the string was well-formed but empty at that address, or unusable as a string.
A success check here is simple: run it twice on a row you know is good and a row you know is bad. If the good row returns 0 and the bad one returns 2 or 4, the function is behaving as expected and you can trust its verdicts on the unknowns. One caveat: ROWID_VERIFY can return a nonzero code for a table you don't have permission to read, so confirm access level before concluding a row is gone.
Method 2: Cross-Check the Encoded Table Object
Before you trust any verification result, confirm the ROWID actually claims to belong to the table you're testing. Extract the object number with DBMS_ROWID.ROWID_OBJECT, then compare it to the table's object ID from USER_OBJECTS or DBA_OBJECTS.
A mismatch (verify code 1) usually means one of three things:
The ROWID was copied from a different table, perhaps during a botched migration. The table was dropped and recreated, giving it a new object ID even if the name is identical. Old ROWIDs then point into the same datafiles under a now-nonexistent object number — a classic stale-data trap. A partition operation (exchange, split, move) reorganized the segment and changed the physical addresses.
This is the single most common false alarm. An application complains its stored ROWIDs are invalid, and the real problem is that a TRUNCATE plus reload or a table recreate changed the object ID while the application kept the old addresses. Comparing ROWID_OBJECT to the current object ID catches that in one query.
Method 3: DUMP the ROWID to Diagnose Malformed Strings
When a string fails validation but you don't know why, DUMP shows the bytes. For an extended ROWID, the hex output reveals whether the type byte says extended (type 1) versus restricted (type 0), and whether individual fields contain garbage from a bad copy.
A practical workflow: dump both a known-good ROWID and the suspect one from the same table. If the good one begins with a clean structured header and the suspect one has extra or odd bytes, the suspect was likely stored in a VARCHAR2 field that was truncated or padded. Padding with spaces is the trap here — many systems store ROWIDs in VARCHAR2(18) and quietly pad shorter legacy restricted ROWIDs, which then fail extended-format parsing.
The fix in those cases isn't a database change. It's a data-cleaning step in whatever stores the strings, such as trimming and enforcing the 18-character length before use.
Method 4: Probe With a Direct Query
The oldest test is the most direct: select by the ROWID and see whether any rows come back.
Zero rows means the address is dead — either the row was deleted or the block no longer belongs to this object. An ORA-01410 ("invalid ROWID") error means Oracle couldn't even parse the address, so treat that string as malformed and go back to Method 3.
This probe is cheap and doesn't need catalog access, but it strips away the diagnostic granularity ROWID_VERIFY gives you. I use it as a confirmation step after verification flags something, not as the first move, because "zero rows" alone doesn't tell you whether the row was deleted, migrated, or the address was never valid.
Method 5: Exceptional Handling for Bulk Stored ROWIDs
When you have thousands of stored ROWIDs to test — a common situation during an upgrade, a table reorganization, or a data migration — a set-based approach beats looping. Create a small helper that runs ROWID_VERIFY against each stored value and captures the return code, then filter for non-zero results.
The pattern in outline (no assertion about the exact syntax beyond the core function):
Isolate the non-zero rows into their own table. That's your invalid set. For big tables this can be slow, because verification does slightly more than a plain lookup, so run it off-peak or on a replica. If performance matters, batch by fetching the candidate ROWIDs in chunks and running the verify call over each batch rather than as one giant statement.
Symptom vs. cause quick map:
| Symptom | Likely cause | First check |
|---|---|---|
| ROWID_VERIFY returns 1 | Wrong table or recreated table | Compare ROWID_OBJECT to current object ID |
| Returns 2 | Row deleted or never existed | Confirm with direct query |
| Returns 4 | Malformed string | DUMP the bytes, check length and padding |
| ORA-01410 on select | Unparseable ROWID | Length and character-set sanity check |
| Works in staging, fails in prod | Object IDs differ between environments | Compare DBA_OBJECTS in both |
That table is the fastest triage path I can give; it collapses five separate investigations into one lookup.
Common Failure Cases and Where They Bite
Deleted rows and block reuse. Delete a row, and its block can be reused by another row or another object. The old ROWID doesn't "point to the next row" in any meaningful sense — it points to whatever now occupies that row slot, or to nothing. Deleted-row reuse is why reusing stored ROWIDs across weeks is dangerous even within the same table.
Table reorganization. ALTER TABLE ... MOVE, partition exchanges, and tablespace moves rewrite physical addresses. Every pre-move ROWID becomes suspect at once. If your verification returns a flood of code 2 after a maintenance window, the maintenance is the cause.
Copy between environments. A staging ROWID pasted into production code is meaningless because the object ID differs. This is common in test data that hops databases; the fix is to store business keys, not row addresses.
Chained or migrated rows. A migrated row moves its data to another block, leaving a forward in the original slot. The ROWID still resolves, but performance drags. ROWID_VERIFY returns valid, so this isn't an "invalid" case — it's a stale-perf case that fools people into a ROWID hunt that has no bad ROWID to find.
ROWID and partitioning. For partitioned tables, ROWIDs encode the partition's segment and are valid only while that partition exists. Dropping a partition invalidates the ROWIDs of every row it held. DBMS_ROWID.ROWID_OBJECT can help identify which segment a string references.
Stop Conditions: When to Escalate
A few situations call for a DBA or vendor support rather than a deeper self-diagnosis:
Verification returns code 3 repeatedly on rows that should be idle — lock or consistency issues against an active segment need coordination. An error log shows systematic failures across many stored ROWIDs and you can't correlate it to any change you made; that points to a bug or a data-integrity event outside your access. You need to test ROWIDs on a table you can read but not verify against because of permissions; get the grant evaluated rather than probing with workarounds. The source data stores restricted ROWIDs whose format you can't confirm; converting them to extended form requires knowing the source segment, and guessing refurbishes bad data.
In those cases, stop modifying data and preserve a snapshot of the failing ROWIDs and their context (table, schema, object ID, timestamp) for the handoff.
Making ROWIDs Safe to Use at All
The most durable lesson from a ROWID hunt is architectural rather than diagnostic. ROWIDs are physical addresses, and physical addresses change through deletions, moves, partition events, and environment copies. They are perfect for short-lived work — a cursor's current row, an in-transaction batch — and dangerous as durable identifiers stored across sessions, backups, or systems.
A better habit: store a primary key from the business data and resolve to ROWID only when you need a fast direct hit. If you must persist ROWIDs, record the table's object ID alongside them and treat any change in object ID as a full invalidation. And if you inherit an application that stores ROWIDs, build a periodic consistency check with ROWID_VERIFY and alert on non-zero codes — it catches the stale-address problem before users do.
The takeaway from the whole exercise: decide whether you're holding a malformed string, a stale address, or a mismatched table first, and the rest of the diagnosis follows from a single function's return code.