Thread: How to split a table?
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?
Regards,
Felix
Felix Zhang <felix.zhang.2005@gmail.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? Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknow) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
Perhaps something like: CREATE TABLE foo2 AS SELECT * FROM foo WHERE (rand() <= 0.60); ? HTH, Greg Williamson DBA GlobeXplorer LLC -----Original Message----- From: pgsql-sql-owner@postgresql.org on behalf of Andreas Kretschmer Sent: Tue 10/17/2006 1:34 AM To: pgsql-general@postgresql.org; pgsql-sql@postgresql.org; pgsql-novice@postgresql.org Cc: Subject: Re: [SQL] [GENERAL] How to split a table? Felix Zhang <felix.zhang.2005@gmail.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? Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknow) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889° ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match ------------------------------------------------------- Click link below if it is SPAM gsw@globexplorer.com "https://mailscanner.globexplorer.com/dspam/dspam.cgi?signatureID=4534936b271274356172766&user=gsw@globexplorer.com&retrain=spam&template=history&history_page=1" !DSPAM:4534936b271274356172766! -------------------------------------------------------
to do some statistics analysis.
2006/10/17, Andreas Kretschmer <akretschmer@spamfence.net>:
Felix Zhang <felix.zhang.2005@gmail.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?
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknow)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
On Tue, Oct 17, 2006 at 03:39:21PM +0800, Felix Zhang wrote: > 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? i do my A/B-Group splitting usually by &1 the serial of the table. assuming, that there are no irregularities in the process of creating your entries, this should give a 50/50 split, which is reuseable for future things and there never is a intersection of the two groups. -- cu