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?
PostgreSQL describe table is defined as check the structure of table, we can describe the structure of table by using \d and table name command in PostgreSQL. In PostgreSQL describe table statement is not present like MySQL instead of describe we have using \d table name and \d+ table name.
To copy a table with partial data from an existing table, users can use the following statement: Syntax: CREATE TABLE new_table AS SELECT * FROM existing_table WHERE condition; The condition in the WHERE clause of the query defines which rows of the existing table will be copied to the new table.
To list the tables in the current database, you can run the \dt command, in psql : If you want to perform an SQL query instead, run this: SELECT table_name FROM information_schema.
The standard way of exporting database schema is pg_dump:
#!/bin/sh
pg_dump --schema-only MYDBNAME > output-file.sql
Sligtly better way combines pg_dump with pg_restore list filtering:
#!/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
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With