pg_dump limit 1000 rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

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?

Thanks

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux