使用R在postgres中设置模式名称

时间:2017-02-09 14:57:58

标签: r postgresql

我使用R连接到PostgreSQL数据库。使用以下功能完成连接:

dbConnect(m, dbname=dbname, host=host, port=port, user=user, password=password)

m是驱动程序(postgres)。

但它不允许我设置我的表所在的特定模式名称。如何连接到特定模式,以便每次我不必将模式名称作为表名前缀?

R中是否有set search_path = 'myschema'的等效声明?

1 个答案:

答案 0 :(得分:1)

您可以使用:

dbConnect(
  m,
  dbname=dbname,
  host=host,
  port=port,
  user=user,
  password=password,
  options="-c search_path=myschema"
)

适用于RPostgreSQL以及RPostgres