R: Remove a table from the database

dbRemoveTable {DBI} | R Documentation

## Remove a table from the database

### Description

Remove a remote table (e.g., created by `dbWriteTable()`) from the database.

#### Methods in other packages

- `DBI::dbRemoveTable("DBIConnection", "Id")`

### Usage

    dbRemoveTable(conn, name, ...)

### Arguments

`conn` | A DBIConnection object, as returned by `dbConnect()`.
`name` | A character string specifying a DBMS table name.
`...` | Other parameters passed on to methods.

### Value

`dbRemoveTable()` returns `TRUE`, invisibly. If the table does not exist, an error is raised. An attempt to remove a view with this function may result in an error.

An error is raised when calling this method for a closed or invalid connection. An error is also raised if `name` cannot be processed with `dbQuoteIdentifier()` or if this results in a non-scalar.

### Specification

A table removed by `dbRemoveTable()` doesn't appear in the list of tables returned by `dbListTables()`, and `dbExistsTable()` returns `FALSE`. The removal propagates immediately to other connections to the same database. This function can also be used to remove a temporary table.

The `name` argument is processed as follows, to support databases that allow non-syntactic names for their objects:

- If an unquoted table name as string: `dbRemoveTable()` will do the quoting, perhaps by calling `dbQuoteIdentifier(conn, x = name)`

- If the result of a call to `dbQuoteIdentifier()`: no more quoting is done

### See Also

Other DBIConnection generics: `DBIConnection-class`, `dbDataType`, `dbDisconnect`, `dbExecute`, `dbExistsTable`, `dbGetException`, `dbGetInfo`, `dbGetQuery`, `dbIsValid`, `dbListFields`, `dbListObjects`, `dbListResults`, `dbListTables`, `dbReadTable`, `dbSendQuery`, `dbSendStatement`, `dbWriteTable`

### Examples

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

    dbExistsTable(con, "iris")
    dbWriteTable(con, "iris", iris)
    dbExistsTable(con, "iris")
    dbRemoveTable(con, "iris")
    dbExistsTable(con, "iris")

    dbDisconnect(con)

[Package DBI version 0.8 Index]