我有一个 Access 数据库,其中包含(理论上(在设计视图中可见的字段描述。我没有访问权限的副本。我可以使用 mdbtools 导出数据和模式,但这些没有附带说明。有没有办法以编程方式提取这些描述?
事实证明,有一个未记录/未记录的 mdbutils 命令将提供表的元数据:mdb-prop
。这是一个 shell 脚本,它将列出每个字段的元数据,改编自我忘记其出处的脚本:
#!/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