get_keys: Get the primary or foreign keys on a table (if any)

View source: R/pmap_db_utilities.R

get_keysR Documentation

Get the primary or foreign keys on a table (if any)

Description

Function returns a character vector of column name(s) that are the primary or foreign key(s) (see keytype), given a schema, and table name

Usage

get_keys(
  table,
  schema = "dbo",
  keytype = c("PRIMARY", "FOREIGN"),
  engine = default_engine
)

Arguments

table

a string name of table to search

schema

a string name of schema to search;default="dbo"

keytype

one of either 'PRIMARY' (default) or 'FOREIGN'

engine

a dbConnect connection object; by default will look in namespace for default_engine

Value

a character vector of column(s) making up the primary key or foreign key(s) on the table

Examples

get_keys('encounters', schema="dbo", engine = myconnection)
get_keys('encounters', schema="dbo", keytype='FOREIGN', engine=myconnection)


lmullany/pmap_utilities documentation built on July 30, 2023, 8:54 a.m.