我有一个这样的数据库
library(RSQLite)
test <- dbConnect(RSQLite::SQLite(), "")
dbWriteTable(test, "mtcars", mtcars)
char_string <- "test"
如何使用
char_string
和 dbListTables
来查看数据库中的表?
列出所有表的通用原始 SQLite 查询是:
SELECT name FROM sqlite_master WHERE type = 'table';
您可以从 R 端执行此查询,使用:
library(RSQLite)
test <- dbConnect(RSQLite::SQLite(), "")
sql <- "SELECT name FROM sqlite_master WHERE type = 'table'"
tables <- dbGetQuery(test, sql)
tables