List database tables {RPgSQL}R Documentation

list database tables

Description

db.ls lists the database table names in the current database. db.rm drops database tables. Use carefully! db.table.exists check if a table name exists in the current database.

Usage

db.ls(pattern, all=F)
db.rm(..., pattern, ask=T)
db.table.exists(name)

Arguments

pattern A matching pattern or table name
all A boolean indicating whether to list system tables in addition to user tables
... One or more character strings that specify the tables to drop from the database
ask A boolean indicating whether to ask for user approval before dropping each table
name A character string containing a table name

Value

db.ls A list of table names
db.table.exists A boolean

Note

The pattern can be any valid PostgreSQL regular expression, so db.rm(pattern='.*', ask=F) will remove all of your database tables. You have been warned.

Author(s)

Timothy H. Keitt

See Also

ls, rm

Examples

if (db.connection.open()) {
  db.ls(all=T)
  data(OrchardSprays)
  rpgsql.test.data <- OrchardSprays
  rm(OrchardSprays)
  db.write.table(rpgsql.test.data, no.clobber=F)
  if (db.table.exists('rpgsql_test_data')) {
    cat(db.ls(pattern='rpgsql'), "\n")
    db.rm('rpgsql_test_data', ask=F)
    cat(db.ls(pattern='test_data'), "\n")
  }
  rm(rpgsql.test.data)
}