I wanna do a minimal dump DB file. (I'm using PostgreSQL 9.2)
So I was thinking about getting the last 1000 rows data from some tables....
I could do something like:
pg_dump dbname --schema-only -f db_schema.sql
CREATE OR REPLACE FUNCTION _save_top_1000_row_tables(chemin file_path) RETURNS character varying AS $BODY$declare _temps timestamp without time zone; begin execute 'copy (SELECT * FROM table1 limit 1000 offset 0) TO ''' || file_path||'table1.txt'''; execute 'copy (SELECT * FROM table2 limit 1000 offset 0) TO ''' || file_path||'table2.txt'''; execute 'copy (SELECT * FROM table3 limit 1000 offset 0) TO ''' || file_path||'table3.txt'''; return ('OK'); end;$BODY$ LANGUAGE plpgsql VOLATILE COST 100;
But using the "COPY" I wouldn't have my foreign keys right? Is there any other option/idea?