% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/advanced.R
\name{mdb_schema}
\alias{mdb_schema}
\title{Generate Schema DDL or Column Types}
\usage{
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
)
}
\arguments{
\item{path}{Path to \code{.mdb}/\code{.accdb} file.}

\item{table}{Table name(s). For \code{mode = "ddl"}, defaults to all user tables.
For \code{mode = "legacy"}, exactly one table name must be given.}

\item{mode}{\code{"legacy"} (default) returns a \code{\link[readr:cols]{readr::cols()}} specification,
matching the k5cents/mdbr canonical API. Requires the \pkg{readr} package.
\code{"ddl"} returns DDL text.}

\item{condense}{Logical; only used when \code{mode = "legacy"}. When \code{TRUE},
passes the col spec through \code{\link[readr:cols_condense]{readr::cols_condense()}}. Default \code{FALSE}.}

\item{namespace}{Prefix identifiers with namespace, equivalent to
\code{-N/--namespace}. Only used when \code{mode = "ddl"}.}

\item{backend}{Target DDL dialect. Supported values are \code{access}, \code{sybase},
\code{oracle}, \code{postgres}, \code{mysql}, and \code{sqlite}. Only used when \code{mode = "ddl"}.}

\item{drop_table}{Issue \verb{DROP TABLE} statements.}

\item{not_null}{Include \verb{NOT NULL} constraints.}

\item{default_values}{Include \code{DEFAULT} values.}

\item{not_empty}{Include \verb{CHECK <> ''} constraints.}

\item{comments}{Include \verb{COMMENT ON} statements.}

\item{indexes}{Export indexes.}

\item{relations}{Request foreign key constraints. Current library-mode
implementation emits a placeholder comment; full FK export is not yet
implemented.}

\item{as_list}{Logical; defaults to \code{TRUE}. When \code{TRUE}, returns a named
\code{mdblist} of DDL text entries keyed by table name. Only used when
\code{mode = "ddl"}.}
}
\value{
When \code{mode = "legacy"}, a \code{\link[readr:cols]{readr::cols()}} specification (optionally
condensed via \code{\link[readr:cols_condense]{readr::cols_condense()}}). Requires the \pkg{readr} package.
When \code{mode = "ddl"} and \code{as_list = TRUE}, a named \code{mdblist} of table-level
DDL text.
}
\description{
\code{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
\code{mode = "legacy"} (the default), it returns a
\link[readr:cols]{readr col spec} for the table instead.
}
\examples{
db <- mdbr:::.mdb_example_nwind_path()
if (nzchar(db)) {
  mdb_schema(db, table = "Products")
  mdb_schema(db, table = "Products", mode = "ddl")
}
}
