dbListObjects: List remote objects

Description Usage Arguments Value Specification See Also Examples

Description

Returns the names of remote objects accessible through this connection as a data frame. This should include temporary objects, but not all database backends (in particular RMariaDB and RMySQL) support this. Compared to dbListTables(), this method also enumerates tables and views in schemas, and returns fully qualified identifiers to access these objects. This allows exploration of all database objects available to the current user, including those that can only be accessed by giving the full namespace.

\Sexpr[results=rd,stage=render]{DBI:::methods_as_rd("dbListObjects")}

Usage

1
dbListObjects(conn, prefix = NULL, ...)

Arguments

conn

A DBIConnection object, as returned by dbConnect().

prefix

A fully qualified path in the database's namespace, or NULL. This argument will be processed with dbUnquoteIdentifier(). If given the method will return all objects accessible through this prefix.

...

Other parameters passed on to methods.

Value

dbListObjects() returns a data frame with columns table and is_prefix (in that order), optionally with other columns with a dot (.) prefix. The table column is of type list. Each object in this list is suitable for use as argument in dbQuoteIdentifier(). The is_prefix column is a logical. This data frame contains one row for each object (schema, table and view) accessible from the prefix (if passed) or from the global namespace (if prefix is omitted). Tables added with dbWriteTable() are part of the data frame, including temporary objects if supported by the database. As soon a table is removed from the database, it is also removed from the data frame of database objects.

The returned names are suitable for quoting with dbQuoteIdentifier(). An error is raised when calling this method for a closed or invalid connection.

Specification

The table object can be quoted with dbQuoteIdentifier(). The result of quoting can be passed to dbUnquoteIdentifier(). The unquoted results are equal to the original table object. (For backends it may be convenient to use the Id class, but this is not required.)

The prefix column indicates if the table value refers to a table or a prefix. For a call with the default prefix = NULL, the table values that have is_prefix == FALSE correspond to the tables returned from dbListTables(),

Values in table column that have is_prefix == TRUE can be passed as the prefix argument to another call to dbListObjects(). For the data frame returned from a dbListObject() call with the prefix argument set, all table values where is_prefix is FALSE can be used in a call to dbExistsTable() which returns TRUE.

See Also

Other DBIConnection generics: DBIConnection-class, dbAppendTable, dbCreateTable, dbDataType, dbDisconnect, dbExecute, dbExistsTable, dbGetException, dbGetInfo, dbGetQuery, dbIsReadOnly, dbIsValid, dbListFields, dbListResults, dbListTables, dbReadTable, dbRemoveTable, dbSendQuery, dbSendStatement, dbWriteTable

Examples

1
2
3
4
5
6
7
con <- dbConnect(RSQLite::SQLite(), ":memory:")

dbListObjects(con)
dbWriteTable(con, "mtcars", mtcars)
dbListObjects(con)

dbDisconnect(con)

Example output

[1] table     is_prefix
<0 rows> (or 0-length row.names)
                table is_prefix
1 <Id> table = mtcars     FALSE

DBI documentation built on May 2, 2018, 5:04 p.m.