dbStorage function

Storage Size

Storage Size

Get storage size of tables in a database.

dbStorage(channel, total = TRUE, used = FALSE, unused = FALSE)

Arguments

  • channel: an RODBC connection.
  • total: whether to calculate total storage size.
  • used: whether to calculate used storage size.
  • unused: whether to calculate unused storage size.

Returns

Data frame containing the following columns: - Name: name of table/view.

  • Schema: database schema.

  • Type: type of table/view.

  • Rows: number of rows.

  • Cols: number of columns.

In addition, any of the following columns, depending on which of total, used, and unused are TRUE: - TotalKB: total storage size.

  • UsedKB: used storage size.

  • UnusedKB: unused storage size.

Note

Based on https://stackoverflow.com/questions/7892334.

Examples

## Not run: con <- odbcConnect("myDatabase") dbOverview(con) dbOverview(con, dim=FALSE, peek=FALSE) ## End(Not run)

See Also

sqlQuery is the underlying function used to query sys.tables, sys.indexes, sys.partitions, sys.allocation_units, and sys.schemas.

dbOverview shows the dimensions of tables/views and the first column names, and dbTime shows the time when tables/views were created and last modified.

object.size is the base function to return the storage size of objects inside the R workspace.

MSSQL-package gives an overview of the package.