pg_dump limit 1000 rows

From: "drum(dot)lucas(at)gmail(dot)com" <drum(dot)lucas(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: pg_dump limit 1000 rows
Date: 2016-03-03 00:56:12
Message-ID: CAE_gQfXRQgbKqvO=0c7DmtWaQWqhdgP=2Q9Z-LSQ_Lk3wOx1tQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message bricklen 2016-03-03 01:04:24 Re: pg_dump limit 1000 rows
Previous Message Moreno Andreo 2016-03-02 18:54:07 Re: [SPAM] Re: autovacuum disk IO