1

I have an Access database with field descriptions that (theoretically) are visible in Design View. I don't have a copy of access. I can export the data and schema using mdbtools, but those don't come with the descriptions. Are there ways to programmatically extract those descriptions?

Erik A
  • 31,639
  • 12
  • 42
  • 67
Matt Hampel
  • 5,088
  • 12
  • 52
  • 78

1 Answers1

1

Turns out there was an un/under-documented mdbutils command that will give metadata for a table: mdb-prop. Here's a shell script that will list out the metadata of every field, adapted from a script whose provenance I have forgotten:

#!/usr/bin/env bash
# Usage: mdb-export-all.sh full-path-to-db

command -v mdb-tables >/dev/null 2>&1 || {
    echo >&2 "I require mdb-tables but it's not installed. Aborting.";
    exit 1;
}

command -v mdb-export >/dev/null 2>&1 || {
    echo >&2 "I require mdb-export but it's not installed. Aborting.";
    exit 1;
}

fullfilename=$1
filename=$(basename "$fullfilename")
dbname=${filename%.*}

mkdir "$dbname"

IFS=$'\n'
for table in $(mdb-tables -1 "$fullfilename"); do
    echo "Check table $table"

    # Save a file with with all metadata for every field
    mdb-prop "$fullfilename" "$table" > "$dbname/$table.txt"

    # Save a file with with just the descriptions:
    cat "$dbname/$table.txt" | grep -E 'name|Description' > "$dbname/info_$table.txt"
done
Matt Hampel
  • 5,088
  • 12
  • 52
  • 78