Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 9FFD09FB411 for ; Tue, 17 Oct 2006 06:10:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 51968-02 for ; Tue, 17 Oct 2006 09:10:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from matrix.gatewaynet.com (host2.dynacom.ondsl.gr [62.103.35.210]) by postgresql.org (Postfix) with ESMTP id DE9A19FB318 for ; Tue, 17 Oct 2006 06:10:05 -0300 (ADT) Received: from host3.dynacom.ondsl.gr ([62.103.35.211] helo=ip216.internal.net) by matrix.gatewaynet.com with esmtp (Exim 4.62) (envelope-from ) id 1GZkxU-0006Hw-O3 for pgsql-sql@postgresql.org; Tue, 17 Oct 2006 12:10:00 +0300 From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: pgsql-sql@postgresql.org Subject: Re: [GENERAL] How to split a table? Date: Tue, 17 Oct 2006 12:09:59 +0300 User-Agent: KMail/1.9.3 References: <20061017083418.GA3917@KanotixBox> In-Reply-To: <20061017083418.GA3917@KanotixBox> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-7" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200610171210.00269.achill@matrix.gatewaynet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200610/162 X-Sequence-Number: 26551 =D3=F4=E9=F2 =D4=F1=DF=F4=E7 17 =CF=EA=F4=FE=E2=F1=E9=EF=F2 2006 11:34, =EF= /=E7 Andreas Kretschmer =DD=E3=F1=E1=F8=E5: > Felix Zhang schrieb: > > Hi, > > > > I want to split a table to 2 small tables. The 1st one contains 60% > > records which are randomly selected from the source table. > > How to do it? > > Why do you want to do this? In any case, you could write a program in perl and insert into the second=20 table rows from the first table, using a techique of generarting random=20 double precision numbers in a predetermined range (lets say 0 to 2^31-1), a= nd=20 then converting this number to your "range" like this: let your number be r. let your table's cardinality be N. then let R=3D(N*r/(2^31))+1 select a source row from your table like: select * from srctable order by pk offset , and then insert this row to your desttable. > > > Andreas =2D-=20 Achilleas Mantzios