sqlrpostgresqlrpostgresql

drob tables their names begin with numbers in postgress using RPostgreSQL


I try to drop tables in an scheme their names begin with digits from R. The tables exist in a postgress data bank.

library(RPostgreSQL)
library(DBI)
pg = dbDriver("PostgreSQL")
con = dbConnect(pg, user= ....)
dbGetQuery(con,paste0("DROP TABLE frc_rm.",'"30062020RB"',";"))

where con containes the login information. However, the command cannot be executed!

In postgresqlQuickSQL(conn, statement, ...) :
  Could not create execute: DROP TABLE frc_rm."30062020RB";

any idea what could be the solution?


Solution

  • Pretty sure this is issue on R side with the function you are using:

    https://www.rdocumentation.org/packages/DBI/versions/0.5-1/topics/dbGetQuery

    " Details

    This function is for SELECT queries only. Some backends may support data manipulation statements through this function for compatibility reasons. However callers are strongly advised to use dbExecute for data manipulation statements. "