我使用
RPostgreSQL读写数据.从任何模式中读取都可以完美地工作,但是我无法写入非公开模式.例如,以下代码将公用模式中的表放置在名称为myschema.tablex中
# write dataframe to postgres drv <- dbDriver("Postgresql") con <- dbConnect(drv,host="localhost",user="postgres",password="zzzz",dbname="mydatabase",port="5436") if(dbExistsTable(con,"myschema.tablex")) { dbRemoveTable(con,"myschema.vkt_tablex")} dbWriteTable(con,"myschema.tablex",dataframe,row.names=F)
我想做的是将表tablex放在MysqL中.我还尝试在连接中命名模式:dbname =“mydatabase.myschema”,并尝试在之前的错误中提到的参数schemaname.
创建对象的默认模式由
原文链接:https://www.f2er.com/postgresql/192672.htmlsearch_path
定义.一种方法是相应地进行设置.例如:
SET search_path = myschema,public;
我引用manual:
When objects are created without specifying a particular target
schema,they will be placed in the first schema listed in the search
path. An error is reported if the search path is empty.
您也可以将其设为default for a role,因此此角色会为每个连接自动设置.更多:
> How does the search_path influence identifier resolution and the “current schema”