mdb-sql
Query MDB (Microsoft Access) files using SQL
SYNOPSIS
mdb-sql [options]
<mdb-file> [sql-statement]
PARAMETERS
<mdb-file>
The Microsoft Access database file to query.
[sql-statement]
The SQL statement to execute. If omitted, mdb-sql reads from standard input.
-d, --delimiter <delimiter>
Specifies the column delimiter for output. The default is ','. Useful for CSV generation.
-H, --no-header
Prevents printing column names (header row) in the output.
-N, --no-row-count
Suppresses the display of the total number of rows returned by the query.
-F, --formatted
Enables pretty printing of the output, often for better human readability.
-S, --schema
Prints schema information (column names and types) before each result set. Useful for understanding table structure.
-R, --raw
Outputs data in raw format, disabling quoting or escaping of values. This can be useful for direct piping.
-q, --quiet
Suppresses warnings and informational messages during execution.
-i, --input-file <file>
Reads the SQL query from the specified file instead of standard input.
-o, --output-file <file>
Writes the query output to the specified file instead of standard output.
--version
Displays the mdbtools version and exits.
--help
Prints a help message and exits.
DESCRIPTION
mdb-sql is a utility from the mdbtools suite designed to execute SQL queries directly against Microsoft Access (.mdb) database files on non-Windows platforms. It provides a command-line interface for interacting with proprietary MDB data, allowing users to extract and analyze information without requiring Microsoft Access or a Windows environment. This tool translates standard SQL statements into operations compatible with the MDB format, making it invaluable for data migration, reporting, and scripting database interactions. While primarily focused on read operations, it bridges the gap for accessing data stored in legacy or proprietary Access database files.
CAVEATS
MDBTools are primarily designed for reading data from Access files. While some UPDATE/DELETE operations might be partially supported, INSERT operations are generally not, and modifying MDB files using these tools is not recommended due to potential data corruption. The supported SQL dialect is a subset of standard SQL and may not fully support complex joins, subqueries, or advanced functions found in other SQL databases. Character encoding issues can also arise, especially with older Access versions or non-UTF-8 data.
SQL DIALECT AND LIMITATIONS
The SQL dialect supported by mdb-sql is specific to mdbtools and aims to translate SQL into operations understandable by the proprietary MDB format. Users should be aware that advanced SQL features like complex correlated subqueries, stored procedures, or triggers are generally not supported. It is best suited for SELECT statements, basic joins, and filtering.
INTERACTIVE AND SCRIPTED USE
mdb-sql can be used interactively by simply running the command and then typing SQL statements, or by piping SQL into it. For scripting, SQL queries can be provided as a command-line argument directly, or from an input file using the -i option, making it suitable for automated data extraction tasks.
HISTORY
Part of the mdbtools open-source project, mdb-sql was developed to enable non-Microsoft platforms (primarily Unix/Linux) to access and manage data within proprietary Microsoft Access (.mdb) database files. This project addresses a long-standing need for interoperability, evolving to support various Access file formats and providing a critical tool for data migration and analysis outside the Windows ecosystem.
SEE ALSO
mdb-tables(1), mdb-schema(1), mdb-export(1), mdb-ver(1), sqlite3(1)