Object view (definitions)

The DDL of the selected object, reconstructed from the catalogs and the server's pg_get_*def functions — pgAdmin's SQL tab. Read only.

The Default tab follows the tree

One catalog query with the object's OID as bind parameter, sent after the tree cursor has rested 200 ms. A result for a row the cursor has left is discarded.

What a definition contains

The layout follows pgAdmin: a header comment, the DROP as a comment, the CREATE, then OWNER, COMMENT, GRANT and the dependent parts.

-- Table: sales.customer

-- DROP TABLE IF EXISTS sales.customer;

CREATE TABLE IF NOT EXISTS sales.customer
(
    customerid integer NOT NULL DEFAULT nextval('sales.customer_customerid_seq'::regclass),
    ...
    CONSTRAINT "PK_Customer_CustomerID" PRIMARY KEY (customerid),
    ...
)
TABLESPACE pg_default;

ALTER TABLE IF EXISTS sales.customer
    OWNER to postgres;

COMMENT ON TABLE sales.customer
    IS 'Current customer information. Also see the Person and Store tables.';

GRANT SELECT ON TABLE sales.customer TO reporting;

-- Index: ix_customer_territoryid

CREATE INDEX IF NOT EXISTS ix_customer_territoryid
    ON sales.customer USING btree (territoryid);
ObjectIts definition also includes
Table, partitionConstraints, partition key, then indexes, triggers, rules and policies.
ViewRules and triggers.
Materialized viewIndexes.
Column, constraint, index, trigger, rule, policyOnly the statement that adds that part.
PartSource
View and materialized view querypg_get_viewdef()
Function, procedure, trigger functionpg_get_functiondef()
Indexpg_get_indexdef()
Constraint (table and domain)pg_get_constraintdef()
Triggerpg_get_triggerdef()
Rulepg_get_ruledef()
Partition keypg_get_partkeydef()
Defaults and other stored expressionspg_get_expr()
Type namesformat_type()
Commentsobj_description(), col_description()
PrivilegesThe ACL through aclexplode(), as GRANT statements.

The rest — CREATE TABLE, SEQUENCE, TYPE, roles, databases, schemas — is assembled by pgtc from catalog columns. Names are schema-qualified and quoted with quote_ident().

A group row lists its objects; a server row shows its parameters and pg_settings — see Connections.

Reading a definition

F6 (or Alt+2) moves from the tree into the text and back. It is the query tab's editor in read-only mode: moving, selecting, copying and Ctrl+F work. Lines are not wrapped.

Keeping a definition open: F3

A view in its own tab
F3 on the view vindividualcustomer.

F3 in the tree opens the object in its own tab, which does not follow the tree cursor. It is a snapshot: later DDL does not update it.

Changing an object: Edit in new query tab (Ctrl+E)

pgtc has no property dialogs. Ctrl+E (View → Edit in new query tab, context menu) copies the shown definition into a new query tab with a session on the object's database.

A definition in a query tab
The definition of the view in a query tab.
ObjectThe text in the query tab
Function, procedure, viewCREATE OR REPLACE …: executable as it is.
TableCREATE TABLE IF NOT EXISTS …: a no-op on the existing table; a reference for ALTER TABLE.
Index, trigger, constraint, policyUncomment the DROP line to re-create.

Refused, with a hint in the status line:

For CREATE and DROP from a form, see the developer templates (F7).