dm (version 0.2.8)

dm_rm_pk: Remove a primary key

Description

dm_rm_pk() removes one or more primary keys from a table and leaves the dm object otherwise unaltered. An error is thrown if no private key matches the selection criteria. If the selection criteria are ambiguous, a message with unambiguous replacement code is shown. Foreign keys are never removed.

Usage

dm_rm_pk(dm, table = NULL, columns = NULL, ..., fail_fk = TRUE)

Arguments

dm

A dm object.

table

A table in the dm. Pass NULL to remove all matching keys.

columns

Table columns, unquoted. To refer to a compound key, use c(col1, col2). Pass NULL (the default) to remove all matching keys.

...

These dots are for future extensions and must be empty.

fail_fk

Boolean: if TRUE (default), will throw an error if there are foreign keys addressing the primary key that is to be removed.

Value

An updated dm without the indicated primary key(s).

See Also

Other primary key functions: dm_add_pk(), dm_get_all_pks(), dm_has_pk(), enum_pk_candidates()

Examples

Run this code
# NOT RUN {
dm_nycflights13() %>%
  dm_rm_pk(airports, fail_fk = FALSE) %>%
  dm_draw()
# }

Run the code above in your browser using DataLab