Object tags
Tags are searchable key/value pairs in the catalog. The validated workflow covers named relations, schemas, and CHECK/foreign-key constraints. Tags are separate from comments, which remain free-form text.
ALTER TABLE public.users ADD TAG env = 'prod', team = 'finance';
ALTER TABLE public.users ADD TAG env = 'staging'; -- replaces the key's value
ALTER TABLE public.users DROP TAG team;
ADD TAG creates or replaces a key’s value. DROP TAG removes one or more
keys; a missing key leaves the catalog unchanged. For OID-backed objects that
are not relations, use ALTER OBJECT with an explicit type:
ALTER OBJECT DOMAIN public.status ADD TAG owner = 'registry';
ALTER OBJECT SCHEMA public ADD TAG team = 'platform';
ALTER OBJECT FUNCTION public.normalize ADD TAG stability = 'stable';
ALTER OBJECT PROCEDURE public.transfer_stock ADD TAG purpose = 'inventory movement';
ALTER OBJECT DATABASE analytics ADD TAG environment = 'prod';
ALTER OBJECT SECRET billing_api ADD TAG team = 'finance';
ALTER OBJECT SCHEDULE hourly_cleanup ADD TAG owner = 'platform';
ALTER OBJECT OPCLASS int4_ops ADD TAG category = 'index';
ALTER OBJECT OPERATOR "+" ADD TAG category = 'arithmetic';
ALTER OBJECT recognizes schema, type, domain, function, procedure, aggregate,
role, user, group, tablespace, partition_policy, access_policy,
constraint, trigger, extension, foreign_server, external_connection,
opclass, operator, database, secret, and schedule, as well as relation
types. End-to-end validation for families beyond schemas and CHECK/foreign-key
constraints remains pending. Constraints and triggers use ON <relation> to
disambiguate repeated names. Functions, operators, and operator classes must
have unique names. Casts do not support tags yet because they have no own OID.
Values are SQL strings.
Changes follow the current transaction; renaming a relation preserves its tags,
and dropping it removes its tags.
Query the public view:
SELECT schema_name, object_name, object_kind, key, value
FROM sys.catalog_object_tags
WHERE key = 'env' AND value = 'prod'
ORDER BY schema_name, object_name;
The Console shows tags in the Metadata tab on object details and on the Object Metadata page, which lists taggable objects without a dedicated tree detail. Actions prepare SQL in the editor. Comments remain in a dedicated Comments tab where object details support them. Database tags are cluster-wide; secret and schedule tags belong to the current database catalog. Dumps preserve secret tags, but the secret must be provisioned on the target first; secret values are never exported. Dumps include SQL schedule definitions and tags; native schedules cannot be exported. Extension, operator, and operator-class tag round-trips require the extension to be available on the target. Foreign tables are included without their remote rows when the server, connection, and options can be restored safely. If a tagged foreign server or external connection has opaque options, the dump fails instead of silently dropping its metadata.