Drop a table, a view or a schema.
dbDrop(
conn,
name,
type = c("table", "schema", "view", "materialized view"),
ifexists = FALSE,
cascade = FALSE,
display = TRUE,
exec = TRUE
)
A connection object.
A character string specifying a PostgreSQL table, schema, or view name.
The type of the object to drop, either "table"
, "schema"
,
"view"
, or "materialized view"
.
Do not throw an error if the object does not exist. A notice is issued in this case.
Automatically drop objects that depend on the object (such as views).
Logical. Whether to display the query (defaults to
TRUE
).
Logical. Whether to execute the query (defaults to
TRUE
).
If exec = TRUE
, returns TRUE
if the table/schema/view
was successfully dropped.
## examples use a dummy connection from DBI package
conn <- DBI::ANSI()
dbDrop(conn, name = c("schema", "view_name"), type = "view", exec = FALSE)
#> Query not executed:
#> DROP VIEW "schema"."view_name";
dbDrop(conn, name = "test_schema", type = "schema", cascade = "TRUE", exec = FALSE)
#> Query not executed:
#> DROP SCHEMA "test_schema" CASCADE;