Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bwh5O-0005Rr-53 for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2016 02:58:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bwh5N-00041e-J2 for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2016 02:58:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bwh5L-00041V-WC for pgsql-general@postgresql.org; Wed, 19 Oct 2016 02:58:32 +0000 Received: from zql.com ([206.222.31.58]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bwh5G-0000I3-8S for pgsql-general@postgresql.org; Wed, 19 Oct 2016 02:58:30 +0000 Received: from localhost ([127.0.0.1]) by zql.com with smtp (Exim 4.68) (envelope-from ) id 1bwh5C-0005Zg-Jt; Tue, 18 Oct 2016 22:58:22 -0400 From: "Greg Sabino Mullane" To: pgsql-general@postgresql.org CC: patrickbakerbr@gmail.com CC: patrickbakerbr@gmail.com Subject: Re: pg_sample X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 X-Request-PGP: http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 In-Reply-To: Content-type: text/plain; charset=UTF-8 Date: Wed, 19 Oct 2016 02:58:22 -0000 X-Mailer: JoyMail 3.1.0 Message-ID: X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org -----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 Patrick B writes: ... > However, this new database test server doesn't need to have all the data. I > would like to have only the first 100 rows(example) of each table in my > database. ... This should do what you ask. If the order does not matter, leave out the ORDER BY. This assumes everything of interest is in the public schema. $ createdb testdb $ pg_dump realdb --schema-only | psql -q testdb $ psql realdb psql> \o dump.some.rows.sh psql> select format($$psql realdb -c 'COPY (select * from %I order by 1 limit %s) TO STDOUT' | psql testdb -c 'COPY %I FROM STDIN' $$, table_name, 100, table_name) from information_schema.tables where table_schema = 'public' and table_type = 'BASE TABLE'; psql> \q $ sh dump.some.rows.sh - -- Greg Sabino Mullane greg@turnstep.com End Point Corporation http://www.endpoint.com/ PGP Key: 0x14964AC8 201610182256 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- iEYEAREDAAYFAlgG4NkACgkQvJuQZxSWSsge4ACePhBOBtBFnGNxXt5qpY7X+w3o d04AoKTzAgxcaqy8qfIE0LPuzG9x0KIU =sS+m -----END PGP SIGNATURE----- -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general