Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 24E969FA3D0 for ; Tue, 17 Oct 2006 08:08:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 21301-09 for ; Tue, 17 Oct 2006 08:08:53 -0300 (ADT) 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 678149FA3B4 for ; Tue, 17 Oct 2006 08:08:51 -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 1GZmoP-0006K0-M1 for pgsql-sql@postgresql.org; Tue, 17 Oct 2006 14:08:45 +0300 Content-Disposition: inline From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: pgsql-sql@postgresql.org Subject: Fwd: Re: [GENERAL] How to split a table? Date: Tue, 17 Oct 2006 14:08:44 +0300 User-Agent: KMail/1.9.3 MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-7" Content-Transfer-Encoding: quoted-printable Message-Id: <200610171408.44655.achill@matrix.gatewaynet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.17 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200610/167 X-Sequence-Number: 26556 I forgot to mention that you would have to maintain a counter of each inser= ted=20 row and stop when you reach 60% of N (where N the cardinality of your sourc= e=20 table). =2D--------- =D0=F1=EF=F9=E8=E7=EC=DD=ED=EF =CC=DE=ED=F5=EC=E1 ---------- Subject: Re: [SQL] [GENERAL] How to split a table? Date: =D4=F1=DF=F4=E7 17 =CF=EA=F4=FE=E2=F1=E9=EF=F2 2006 12:09 =46rom: Achilleas Mantzios To: pgsql-sql@postgresql.org =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 table rows from the first table, using a techique of generarting random double precision numbers in a predetermined range (lets say 0 to 2^31-1), a= nd 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- Achilleas Mantzios =2D------------------------------------------------------ =2D-=20 Achilleas Mantzios