dm (version 0.0.3.9003)

cdm_rm_pk: Remove primary key from a table in a dm object

Description

cdm_rm_pk() removes a potentially set primary key from a table in the underlying data_model-object and otherwise leaves the dm object untouched.

Foreign keys pointing to the table from other tables can optionally be removed as well.

Usage

cdm_rm_pk(dm, table, rm_referencing_fks = FALSE)

Arguments

dm

A dm object.

table

A table in the dm

rm_referencing_fks

Boolean: if FALSE (default), will throw an error, if there are foreign keys addressing the primary key to be removed. If TRUE, will in addition to the primary key of parameter table, also remove all foreign key constraints that are pointing to it.

See Also

Other primary key functions: cdm_add_pk, cdm_get_all_pks, cdm_get_pk, cdm_has_pk, enum_pk_candidates

Examples

Run this code
# NOT RUN {
library(dplyr)
nycflights_dm <- cdm_nycflights13()

nycflights_dm %>%
  cdm_rm_pk(airports, rm_referencing_fks = TRUE) %>%
  cdm_has_pk(planes)

nycflights_dm %>%
  cdm_rm_pk(planes, rm_referencing_fks = TRUE) %>%
  cdm_has_pk(planes)
# }

Run the code above in your browser using DataLab