R连接PostgreSQL时dbExistsTable返回FALSE、无法查询指定schema下表的问题
R连接PostgreSQL访问指定Schema表的问题排查
用户尝试连接PostgreSQL目标库访问业务表,配套提供了数据库界面截图作为参考。本次需要调用social schema下的profiles_bstms表,因此编写了数据库连接、表校验的相关代码:
library(RPostgres) library(DBI) pw <- { "1234" } con <- dbConnect(RPostgres::Postgres() , host='1.2.3.4.' , port='5432' , dbname='social' , user='analyst' , password=pw) #rm(pw) # removes the password dbExistsTable(con, "social")
运行现象
- 执行上述代码后,
dbExistsTable的返回结果为:
[1] FALSE
用户已在数据库端确认对应对象实际存在。
- 为排查可见范围问题,用户执行
dbListTables(con)查询当前连接下所有可访问的表,返回结果如下:
> dbListTables(con) [1] "cache" "available_permission_modules" [3] "available_permissions" "counters" [5] "permissions" "group_direction" [7] "jobs" "oauth_auth_codes" [9] "oauth_access_tokens" "oauth_refresh_tokens" [11] "permissions_rules" "permissions_rule_user" [13] "oauth_clients" "oauth_personal_access_clients" [15] "users" "directions" [17] "themes" "profiles_without_rating" [19] "failed_jobs" "model_has_permissions" [21] "regions_oktmo" "ch_profiles" [23] "user_reports" "roles" [25] "migrations" "crime_minor" [27] "governments" "mapping_candidates" [29] "password_resets" "responsible" [31] "spatial_ref_sys" "model_has_roles" [33] "population" "role_has_permissions" [35] "geo_point" "geo_polygon" [37] "crime_all" "geography_columns" [39] "geometry_columns" "raster_columns" [41] "raster_overviews" "schools" [43] "post_grabber"
待解决的问题
- 为什么校验
social对象存在性时返回FALSE? - 为什么返回的可见表列表中没有
social.profiles_bstms表? - 如何正确查询并使用
socialschema下的profiles_bstms表?
内容的提问来源于stack exchange,提问作者psysky
相关产品推荐
相关产品推荐

