alterTABLE {pgTools}R Documentation

Generate a PostgreSQL ALTER TABLE statement, optionally execute the statement if con is not NULL.

Description

Generate a PostgreSQL ALTER TABLE statement, optionally execute the statement if con is not NULL.

Usage

alterTABLE(
  name,
  if_exists = FALSE,
  cascade = FALSE,
  restrict = FALSE,
  action,
  con = NULL
)

Arguments

name

A string, the "name" parameter for PostgreSQL ALTER TABLE statement.

if_exists

TRUE/FALSE, if TRUE, adds "IF EXISTS" to PostgreSQL ALTER TABLE statement.

cascade

TRUE/FALSE, if TRUE, adds "CASCADE" to PostgreSQL ALTER TABLE statement.

restrict

TRUE/FALSE, if TRUE, adds "RESTRICT" to PostgreSQL ALTER TABLE statement.

action

A string or vector of strings, the "action" parameter for PostgreSQL ALTER TABLE statement.

con

A database connection that can be passed to DBI::dbSendQuery/DBI::dbGetQuery.

Value

A string, PostgreSQL ALTER TABLE statement; or the results retrieved by DBI::dbSendQuery after executing the statement.

Examples

alterTABLE("sample", action = c("ADD COLUMN IF NOT EXISTS col4 BOOLEAN"))

[Package pgTools version 1.0.2 Index]