如何从postgresql打印表结构?
我在浏览器中使用 phpPgAdmin,在 Windows 中使用 PgAdmin III。有没有办法打印整个数据库的表结构?
I am using phpPgAdmin in the browser and PgAdmin III for Windows. Is there anyway to take the printout of the table structure for the entire database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
导出数据库模式的标准方法是 pg_dump:
稍微好一点的方法将 pg_dump 与 pg_restore 列表过滤相结合:
如果您更喜欢 GUI 向导, pg_dump 命令可以在 PgAdmin III 中生成:
注意:生成的文件不仅包含表,还包含所有其他对象(视图、函数等)。如果您只需要最少的打印输出,您可以在文本编辑器中编辑此文件并删除不需要的内容。仅保留“类型:表;”项目。
The standard way of exporting database schema is pg_dump:
Sligtly better way combines pg_dump with pg_restore list filtering:
If you prefer GUI wizards, pg_dump command can be generated in PgAdmin III:
Note: the resulting file will have not only tables, but also all other objects (views, functions, etc.). If you need only the minimal printout, you can edit this file in text editor and remove unneeded stuff. Leave only "Type: TABLE;" items.
如果您使用的是 Windows 和 pgAdmin,则 psql 应该位于 C:\Program files\postgresql\\bin\psql 中。
运行 psql,然后您将看到
\d
打印所有表和索引,以及\d
为您提供有关一个表的详细信息。If you are on Windows and pgAdmin, you should have psql somewhere in
C:\Program files\postgresql\<version>\bin\psql
.Run psql and then you have
\d
which prints all tables and indexes and\d <table_name>
which gives you details about one table.您可以根据需要一次执行一项。右键单击 pgAdminIII 中的表,转到“报告”并选择“数据字典报告”。
对于输出格式,选择“XHTML 1.0 Transitional”,选择“嵌入默认样式表”选项,为其指定文件名,然后单击“确定”。
在浏览器中打开 XML 文件并打印。
You can do them one at a time as you need them. Right click on a table in pgAdminIII, go to Reports and select "Data Dictionary Report".
For the output format, select "XHTML 1.0 Transitional", choose "Embed the default stylesheet" option, give it a file name and click OK.
Open the XML file in your browser and print.