Skip to content

Table Operations

Operation: createTable

pgm.createTable( tablename, columns, options )

IMPORTANT

Create a new table - postgres docs

Arguments

NameTypeDescription
tablenameNamename for the new table
columnsobjectcolumn names / options -- see column definitions section
optionsobjecttable options (optional)

Options

OptionTypeDescription
temporarybooleandefault false
ifNotExistsbooleandefault false
inheritsNametable(s) to inherit from
constraintsobjecttable constraints see expression of add constraint
likeName or objecttable(s) to inherit from or object with table and options keys
commentstringadds comment on table

like options

OptionTypeDescription
includingstring or array[string]'COMMENTS', 'CONSTRAINTS', 'DEFAULTS', 'IDENTITY', 'INDEXES', 'STATISTICS', 'STORAGE', 'ALL'
excludingstring or array[string]'COMMENTS', 'CONSTRAINTS', 'DEFAULTS', 'IDENTITY', 'INDEXES', 'STATISTICS', 'STORAGE', 'ALL'

Reverse Operation: dropTable

pgm.dropTable( tablename, options )

IMPORTANT

Drop existing table - postgres docs

Arguments

NameTypeDescription
tablenameNamename of the table to drop
optionsobjectCheck below for available options

Options

OptionTypeDescription
ifExistsbooleandrops table only if it exists
cascadebooleandrops also dependent objects

Operation: renameTable

pgm.renameTable( tablename, new_tablename )

IMPORTANT

Rename a table - postgres docs

Reverse Operation: same operation in opposite direction

Arguments

NameTypeDescription
tablenameNamename of the table to rename
new_tablenameNamenew name of the table

Operation: alterTable

pgm.alterTable( tablename, options )

IMPORTANT

Alter existing table - postgres docs

Arguments

NameTypeDescription
tablenameNamename of the table to alter
optionsobjectCheck below for available options

Options

OptionTypeDescription
levelSecuritystringDISABLE, ENABLE, FORCE, or NO FORCE