pgDropTables: Drop tables from a PostgreSQL database

Description Usage Arguments References Examples

View source: R/db_tables_managment.R

Description

Drop tables from a PostgreSQL database matching a pattern with CASCADE.

Usage

1
pgDropTables(conn, pattern, verbose = TRUE)

Arguments

conn

a PostgreSQLConnection object.

pattern

character; string pattern matching tables names .

verbose

boolean; whether or not drop message must be printed.

References

https://stackoverflow.com/questions/4202135/how-to-drop-multiple-tables-in-postgresql-using-a-wildcard

Examples

1
2
3
4
5
6
7
8
library(RPostgreSQL)
data(mtcars)
conn = dbConnect(drv=dbDriver("PostgreSQL"), host="localhost", port=5432,
                dbname="foodflows", user="milo", password="postgres")
dbWriteTable(conn, "mtcars", mtcars, overwrite=TRUE)
dbWriteTable(conn, "mtcars2", mtcars, overwrite=TRUE)
pgDropTables(conn, "cars") # Will drop the 2
dbDisconnect(conn)

MiloMonnier/postgisr documentation built on Feb. 16, 2021, 8:03 p.m.