Learn R Programming

odbc (version 1.3.5)

dbListFields,OdbcConnection,character-method: List field names of a remote table

Description

Returns the field names of a remote table as a character vector.

DBI:::methods_as_rd("dbListFields")

Usage

# S4 method for OdbcConnection,character
dbListFields(
  conn,
  name,
  catalog_name = NULL,
  schema_name = NULL,
  column_name = NULL,
  ...
)

Value

dbListFields()

returns a character vector that enumerates all fields in the table in the correct order. This also works for temporary tables if supported by the database. The returned names are suitable for quoting with dbQuoteIdentifier().

Arguments

conn

A DBIConnection object, as returned by dbConnect().

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"')

catalog_name

The name of the catalog to return, the default returns all catalogs.

schema_name

The name of the schema to return, the default returns all schemas.

column_name

The name of the column to return, the default returns all columns.

...

Other parameters passed on to methods.

Failure modes

If the table does not exist, an error is raised. Invalid types for the name argument (e.g., character of length not equal to one, or numeric) lead to an error. An error is also raised when calling this method for a closed or invalid connection.

Specification

The name argument can be

A column named row_names is treated like any other column.

Details

% can be used as a wildcard in any of the search parameters to match 0 or more characters. _ can be used to match any single character.

See Also

Examples

Run this code
con <- dbConnect(RSQLite::SQLite(), ":memory:")

dbWriteTable(con, "mtcars", mtcars)
dbListFields(con, "mtcars")

dbDisconnect(con)

Run the code above in your browser using DataLab