1

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?

1
  • 1
    How about: dbExecute(conn, 'DROP TABLE frc_rm."30062020RB"')? Can you run the same command in Postgres using the same user as in R? User may not have create/drop table privileges. Commented Jul 17, 2020 at 22:08

1 Answer 1

1

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. "

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.