我正在浏览器中使用phpPgAdmin和Windows中的PgAdmin III。有没有办法打印出整个数据库表结构的输出?
导出数据库模式的标准方式是使用pg_dump:
#!/bin/sh
pg_dump --schema-only MYDBNAME > output-file.sql
略微更好的方法是将pg_dump与pg_restore列表过滤相结合:
#!/bin/sh
dump=`mktemp`
list=`mktemp`
pg_dump --schema-only MYDBNAME -Fc -f $dump
pg_restore -l $dump | grep ' TABLE ' > $list
pg_restore -L $list $dump > output-file.sql
rm $list $dump
C:\Program files\postgresql\<版本>\bin\psql
中找到psql。\d
,将打印所有表格和索引;输入\d <table_name>
,将提供有关某个表格的详细信息。您可以根据需要一个一个地执行它们。在pgAdminIII中右键单击一个表,转到“报告”并选择“数据字典报告”。
对于输出格式,选择“XHTML 1.0 Transitional”,选择“嵌入默认样式表”选项,给它一个文件名,然后点击“确定”。
在浏览器中打开XML文件并进行打印。
pg_dump
而不是psql
。 - user330315