mdb-schema is a utility program distributed with MDB Tools. It produces
DDL (data definition language) output for the given database, which can be
passed to another database to recreate the Access table structure. With
mode = "legacy" (the default), it returns a
readr col spec for the table instead.
mdb_schema(
path,
table = NULL,
mode = c("legacy", "ddl"),
condense = FALSE,
namespace = NULL,
backend = c("access", "sybase", "oracle", "postgres", "mysql", "sqlite"),
drop_table = FALSE,
not_null = TRUE,
default_values = FALSE,
not_empty = FALSE,
comments = TRUE,
indexes = TRUE,
relations = TRUE,
as_list = TRUE
)Path to .mdb/.accdb file.
Table name(s). For mode = "ddl", defaults to all user tables.
For mode = "legacy", exactly one table name must be given.
"legacy" (default) returns a readr::cols() specification,
matching the k5cents/mdbr canonical API. Requires the readr package.
"ddl" returns DDL text.
Logical; only used when mode = "legacy". When TRUE,
passes the col spec through readr::cols_condense(). Default FALSE.
Prefix identifiers with namespace, equivalent to
-N/--namespace. Only used when mode = "ddl".
Target DDL dialect. Supported values are access, sybase,
oracle, postgres, mysql, and sqlite. Only used when mode = "ddl".
Issue DROP TABLE statements.
Include NOT NULL constraints.
Include DEFAULT values.
Include CHECK <> '' constraints.
Include COMMENT ON statements.
Export indexes.
Request foreign key constraints. Current library-mode implementation emits a placeholder comment; full FK export is not yet implemented.
Logical; defaults to TRUE. When TRUE, returns a named
mdblist of DDL text entries keyed by table name. Only used when
mode = "ddl".
When mode = "legacy", a readr::cols() specification (optionally
condensed via readr::cols_condense()). Requires the readr package.
When mode = "ddl" and as_list = TRUE, a named mdblist of table-level
DDL text.
db <- mdbr:::.mdb_example_nwind_path()
if (nzchar(db)) {
mdb_schema(db, table = "Products")
mdb_schema(db, table = "Products", mode = "ddl")
}