From: | Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: [GENERAL] How to split a table? |
Date: | 2006-10-17 09:09:59 |
Message-ID: | 200610171210.00269.achill@matrix.gatewaynet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice pgsql-sql |
Στις Τρίτη 17 Οκτώβριος 2006 11:34, ο/η Andreas Kretschmer έγραψε:
> Felix Zhang <felix(dot)zhang(dot)2005(at)gmail(dot)com> 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), and
then converting this number to your "range" like this:
let your number be r.
let your table's cardinality be N.
then let R=(N*r/(2^31))+1
select a source row from your table like:
select * from srctable order by pk offset <R>,
and then insert this row to your desttable.
>
>
> Andreas
--
Achilleas Mantzios
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2006-10-17 09:12:38 | Re: [SQL] [GENERAL] How to split a table? |
Previous Message | Felix Zhang | 2006-10-17 09:07:25 | Re: [NOVICE] How to split a table? |
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2006-10-17 09:12:38 | Re: [SQL] [GENERAL] How to split a table? |
Previous Message | Felix Zhang | 2006-10-17 09:07:25 | Re: [NOVICE] How to split a table? |
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2006-10-17 09:12:38 | Re: [SQL] [GENERAL] How to split a table? |
Previous Message | Felix Zhang | 2006-10-17 09:07:25 | Re: [NOVICE] How to split a table? |