table-operations: Operate on SQL tables

create_sql_tableR Documentation

Operate on SQL tables

Description

These functions simply wrap DBI functions to use the standard connection defined in start_sql_connection().

  • create_sql_table() wraps DBI::dbCreateTable()

  • drop_sql_table() wraps DBI::dbRemoveTable()

  • read_sql_table() wraps DBI::dbReadTable()

  • write_sql_table() wraps DBI::dbWriteTable()

  • append_sql_table() wraps DBI::dbAppendTable()

Usage

create_sql_table(name, fields, ..., temporary = FALSE)

drop_sql_table(name, ...)

read_sql_table(name, ...)

write_sql_table(value, name, ...)

append_sql_table(value, name, ...)

Arguments

name

The table name, passed on to dbQuoteIdentifier(). Options are:

  • a character string with the unquoted DBMS table name, e.g. "table_name",

  • a call to Id() with components to the fully qualified table name, e.g. Id(schema = "my_schema", table = "table_name")

  • a call to SQL() with the quoted and fully qualified table name given verbatim, e.g. SQL('"my_schema"."table_name"')

fields

Either a character vector or a data frame.

A named character vector: Names are column names, values are types. Names are escaped with dbQuoteIdentifier(). Field types are unescaped.

A data frame: field types are generated using dbDataType().

...

Other parameters passed on to methods.

temporary

If TRUE, will generate a temporary table statement.

value

a data.frame (or coercible to data.frame).

Details

See the DBI documentation for further information on each function.

name will be simply interpreted by sql_identifier(). If it is a character string containing a fully qualified name (i.e. my_schema.my_table), call sql_identifier() yourself and set parse = TRUE.

write_ and append_sql_table() have the value argument come first, before name. This is an intentional change from their respective DBI functions, so as to facilitate their use with pipes.


pnacht/simplysql documentation built on Sept. 5, 2024, 8:46 p.m.