dbAddKeyEM: Add Key or Check Constraint

Description Usage Arguments Value

View source: R/AmerAssocIndividInvestorsAAII.R

Description

Add a primary or foreign key or check constraint to a table column.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
dbAddKeyEM(
  connName,
  name,
  colname,
  if.not.exists = FALSE,
  only = FALSE,
  const.name = characater(),
  type = c("primary", "foreign", "check"),
  check.by = character(),
  reference,
  colref,
  env,
  display = TRUE,
  exec = TRUE
)

Arguments

connName

String. Default is "connEM". Contains the name of the variable that contains the name of the "connection" in the environment "env".

name

A character string, or a character vector, specifying a PostgreSQL table name.

colname

A character string specifying the name of the column to which the key will be assign; alternatively, a character vector specifying the name of the columns for keys spanning more than one column.

if.not.exists

Logical. Default is FALSE. If TRUE, use pg_ tables to check that in the namespace(schema) the constraint name does not exist. Needed for the check to work is that parameter "const.name" must also be provided.

only

Logical. Default is FALSE. Whether to add to apply this key just to this parent table(TRUE). Otherwise, also apply this constraint to inherited tables(FALSE).

const.name

String. Name of the constraint.

type

The type of the key, either "primary" or "foreign" or "check" constraint

check.by

If type = "check", then the value of the "check". Ignored otherwise.

reference

A character string specifying a foreign table name to which the foreign key will be associated (ignored if type == "primary").

colref

A character string specifying the name of the primary key in the foreign table to which the foreign key will be associated; alternatively, a character vector specifying the name of the columns for keys spanning more than one column (ignored if type == "primary").

env

Environment. Default is the .Global environment. This is the environment to return the connection object "connEM".

display

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

exec

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

Value

TRUE if the key was successfully added.


AndreMikulec/econModel documentation built on June 30, 2021, 9:48 a.m.