Informix Error -512: No References privilege on the referenced columns.
Cause and resolution
No References privilege on the referenced columns.
You do not have References privilege on the referenced columns. The owner of the referenced table or a user who has References privilege with the grant option on that table can grant you this privilege using the GRANT statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-512 is a privilege error specific to foreign keys: creating a REFERENCES constraint requires
the References privilege on the columns being referenced, separate from and in addition to
ordinary SELECT access to them.
CREATE TABLE/ALTER TABLE ... ADD CONSTRAINTwith aREFERENCESclause pointing at columns the session lacks References privilege on — the direct, only cause.- Read access (
SELECT) confused with References privilege — they're granted separately, so being able to query the referenced table doesn't imply the ability to build a foreign key against it. - A cross-schema foreign key to a table owned by a different user, where privileges were never explicitly granted across that ownership boundary.
Solutions / Resolution
- Have the referenced table's owner (or a user holding References privilege with grant
option) grant References privilege, per the official guidance:
GRANT REFERENCES ON parent_table TO app_user; - Grant on specific columns only, if that's sufficient for the foreign key being built:
GRANT REFERENCES (order_id) ON orders TO app_user; - Retry the
CREATE TABLE/ALTER TABLEstatement once the privilege is in place.
Examples
Hitting the restriction
CREATE TABLE order_items (
item_id INT,
order_id INT REFERENCES orders(order_id)
);
-- -512: app_user lacks References privilege on orders.order_id
Granting it and retrying
-- Run by the owner of 'orders':
GRANT REFERENCES (order_id) ON orders TO app_user;
-- Now succeeds:
CREATE TABLE order_items (
item_id INT,
order_id INT REFERENCES orders(order_id)
);
Diagnostic Checks
- Query
systabauth/syscolauthfor existing privileges on the referenced table/columns to confirm whether References privilege specifically (not just Select) has been granted. - Identify the referenced table's owner before requesting the grant, since only the owner or a user with grant-option References privilege can issue it.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -512 in this set yet.
References privilege is separate from Select — being able to query a table doesn't mean a foreign key can be built against it without an explicit grant.