Skip to contents

Lists the tables of a database with their number of columns and their estimated number of rows (DuckDB's own estimate, available without scanning the table). Use it to see what a database holds before querying it, or in a sanity check to verify that row counts do not drop between two runs.

Usage

db_tables(con)

Arguments

con

A DBI connection, or the path of a .duckdb file.

Value

A data.table with table, n_columns and estimated_rows.

See also

Other queries: db_query()

Examples

path <- tempfile(fileext = ".duckdb")
con <- db_connect(path)
#> duckdb is storing downloaded extensions and secrets under ~/.duckdb:
#> ℹ /home/agoutsmedt/.duckdb
#> This persists across sessions and is shared with the DuckDB CLI and other clients.
#> ℹ Run duckdb(shared_home = FALSE) to use a temporary directory instead.
#> ℹ See ?duckdb_storage for details and alternatives.
DBI::dbWriteTable(con, "document", data.frame(doc_id = c("a:1", "a:2")))
db_tables(con)
db_disconnect(con)