For a given table and set of columns a CREATE TABLE statement is generated, including PRIMARY KEY constraint. By default all identifiers in the statement are quoted for generic ANSI SQL compliance, and backend-specific quoting will be used if a connection object is provided.
sql_create_table_ztrax(ZType, TableName, KeepColumns = NULL, .con = DBI::ANSI())
ZType | Either |
---|---|
TableName | Name of table to be added to the database, as it appears in
documentation and raw data file names ( |
KeepColumns | A vector of names of columns to be included in table on
the database, as they appear in documentation ( |
.con | A DBIConnection object, as returned by |
A DBI::SQL() CREATE TABLE SQL statement. The SQL statement is also printed to the console as a message and copied to the clipboard.
library(DBI) con <- dbConnect(RSQLite::SQLite(), ":memory:") sql_create_table_ztrax("ZTrans", "Main", c("TransID", "SalesPriceAmount"), con)#>#> #> #> #># If a set of columns are not provided, all of the tables columns will be included. sql_create_table_ztrax("ZAsmt", "TaxExemption")#>#> #> #> #> #> #># If a connection object is not provided DBI::ANSI() is used to generate an # ANSI-SQL compliant statement sql_create_table_ztrax("ZTrans", "Main", c("TransID", "SalesPriceAmount"))#>#> #> #> #>