dm_sql {dm} | R Documentation |
Create DDL and DML scripts for a dm
a and database connection
Description
Generate SQL scripts to create tables, load data and set constraints, keys and indices.
This function powers copy_dm_to()
and is useful if you need more control
over the process of copying a dm
to a database.
Usage
dm_sql(dm, dest, table_names = NULL, temporary = TRUE)
dm_ddl_pre(dm, dest, table_names = NULL, temporary = TRUE)
dm_dml_load(dm, dest, table_names = NULL, temporary = TRUE)
dm_ddl_post(dm, dest, table_names = NULL, temporary = TRUE)
Arguments
dm |
A |
dest |
Connection to database. |
table_names |
A named character vector or named vector of DBI::Id,
DBI::SQL or dbplyr objects created with |
temporary |
Should the tables be marked as temporary? Defaults to |
Details
-
dm_ddl_pre()
generatesCREATE TABLE
statements (includingPRIMARY KEY
definition). -
dm_dml_load()
generatesINSERT INTO
statements. -
dm_ddl_post()
generates scripts forFOREIGN KEY
,UNIQUE KEY
andINDEX
. -
dm_sql()
calls all three above and returns a complete set of scripts.
Value
Nested list of SQL statements.
Examples
con <- DBI::dbConnect(RSQLite::SQLite())
dm <- dm_nycflights13()
s <- dm_sql(dm, con)
s
DBI::dbDisconnect(con)