In databases that support table inheritance (PostgreSQL) or object sub-types (Oracle), statements issued against a parent table normally include rows from all descendant tables. Prepending the keyword ONLY tells the optimizer to operate solely on the specified table or object type. This applies to SELECT, UPDATE, DELETE, and ALTER TABLE. In PostgreSQL, ONLY can appear before a table name in the FROM clause or after ALTER TABLE. In Oracle, ONLY is used with object tables in the FROM clause. Because it bypasses child tables, queries can run faster and avoid accidental updates to underlying partitions, but you must reference each child explicitly if they are still required.
table_name
(identifier) - The parent table to restrict the statement to.INHERITS, PARTITION OF, ALTER TABLE, SELECT, UPDATE, DELETE
PostgreSQL 7.1
ONLY limits a SELECT or DML statement to the named table so inherited tables or subtypes are skipped.
Put ONLY directly before the table name in SELECT, UPDATE, or DELETE, or after ALTER TABLE when adding or changing constraints.
No, but it is helpful when you need to target just the parent partition for maintenance or sampling.
The statement runs normally. The presence of ONLY has no effect beyond the regular table scan.