Skip to the content
mantichora_/docs

Tables, columns and indexes

On PostgreSQL, the object tree changes structure through forms: each writes the statement, shows it to you under What will run, and runs it only when you press.

Which servers

The forms are written for PostgreSQL itself. On every other kind, and on the servers that only speak PostgreSQL’s protocol, the items stand greyed with the reason: No schema statements are written for this driver, so nothing here can be created, changed or dropped. Their structure is still read into the tree; to change it, write the statement in the console.

Creating

Right-click a node of the tree; what can be made there is under New.

a databaseNew schema…
a schemaNew table…: rows of a column’s name, type and default, each with Not null and Key, which makes it the primary key.
a tableNew index…, and New constraint… written as SQL: primary key (id), or unique, foreign key, check. Grant… gives a right on it.
the foldersof sequences, extensions, partitions and roles: New sequence…, New extension…, New partition… and New role….

Changing a table

Change structure, under Structure on a table, or Ctrl+F6 on the one selected, opens a form with six changes: Add a column, Rename a column, Change a column’s type, Set or take away a column’s default, Make a column required or optional and Drop a column. For a column it shows what depends on it, on the server and in the consoles you have open. Dropping one asks again, because its data cannot be got back.

The other changes are on the nodes themselves: Rename… and Drop… on tables, views, sequences, functions and the rest; an index can be renamed, built again or dropped; a constraint renamed, validated or dropped; a column or a table given a Comment…; a column numbered by the server or no longer; an enum given a value; a partition attached or detached; a role’s attributes changed; a grant revoked.

Before it runs

Every form shows What will run, the statement as the server will receive it, with Copy beside it. Nothing is sent until you press the form’s own button: Apply, Create, Rename, Drop. A drop says This cannot be undone. The data in it goes with it. When the server refuses because other objects depend on it, a second button appears: Drop it and everything named above.