dbColumn: Add or remove a column.

View source: R/all_db_wrapper_fns.R

dbColumnR Documentation

Add or remove a column.

Description

Add or remove a column to/from a table.

Usage

dbColumn(
  conn,
  name,
  colname,
  action = c("add", "drop"),
  coltype = "integer",
  cascade = FALSE,
  display = TRUE,
  exec = TRUE
)

Arguments

conn

A connection object.

name

A character string specifying a PostgreSQL table name.

colname

A character string specifying the name of the column

action

A character string specifying if the column is to be added ("add", default) or removed ("drop").

coltype

A character string indicating the type of the column, if action = "add".

cascade

Logical. Whether to drop foreign key constraints of other tables, if action = "drop".

display

Logical. Whether to display the query (defaults to TRUE).

exec

Logical. Whether to execute the query (defaults to TRUE).

Value

If exec = TRUE, returns TRUE if the column was successfully added or removed.

Author(s)

Mathieu Basille mathieu@basille.org

See Also

The PostgreSQL documentation: http://www.postgresql.org/docs/current/static/sql-altertable.html

Examples

## examples use a dummy connection from DBI package
conn<-DBI::ANSI()
## Add an integer column
dbColumn(conn, name = c("schema", "table"), colname = "field", exec = FALSE)
## Drop a column (with CASCADE)
dbColumn(conn, name = c("schema", "table"), colname = "field", action = "drop",
    cascade = TRUE, exec = FALSE)

rpostgis documentation built on Nov. 20, 2023, 5:07 p.m.