You need to enable JavaScript to run this app. R连接PostgreSQL时dbExistsTable返回FALSE、无法查询指定schema下表的问题
优惠活动
大模型
产品
解决方案
定价
更多

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表?
  • 如何正确查询并使用social schema下的profiles_bstms表?

内容的提问来源于stack exchange,提问作者psysky

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.27 21:45:02