Returns the field names of a remote table as a character vector.
Methods in other packages
This documentation page describes the generics. Refer to the documentation pages linked below for the documentation for the methods that are implemented in various backend packages.
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"')
- ...
Other parameters passed on to methods.
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()
.
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 string
the return value of
DBI::dbQuoteIdentifier()
a value from the
table
column from the return value ofDBI::dbListObjects()
whereis_prefix
isFALSE
A column named row_names
is treated like any other column.
See also
dbColumnInfo()
to get the type of the fields.
Other DBIConnection generics:
DBIConnection-class
,
dbAppendTable()
,
dbAppendTableArrow()
,
dbCreateTable()
,
dbCreateTableArrow()
,
dbDataType()
,
dbDisconnect()
,
dbExecute()
,
dbExistsTable()
,
dbGetException()
,
dbGetInfo()
,
dbGetQuery()
,
dbGetQueryArrow()
,
dbIsReadOnly()
,
dbIsValid()
,
dbListObjects()
,
dbListResults()
,
dbListTables()
,
dbQuoteIdentifier()
,
dbReadTable()
,
dbReadTableArrow()
,
dbRemoveTable()
,
dbSendQuery()
,
dbSendQueryArrow()
,
dbSendStatement()
,
dbUnquoteIdentifier()
,
dbWriteTable()
,
dbWriteTableArrow()
Examples
con <- dbConnect(RSQLite::SQLite(), ":memory:")
dbWriteTable(con, "mtcars", mtcars)
dbListFields(con, "mtcars")
#> [1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear"
#> [11] "carb"
dbDisconnect(con)