From: | "Gregory S(dot) Williamson" <gsw(at)globexplorer(dot)com> |
---|---|
To: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, <pgsql-sql(at)postgresql(dot)org>, <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: [SQL] [GENERAL] How to split a table? |
Date: | 2006-10-17 09:19:47 |
Message-ID: | 71E37EF6B7DCC1499CEA0316A256832802B3E737@loki.wc.globexplorer.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice pgsql-sql |
A crude approach would be to add a column to the original table; then update that based on the rand() call:
update foo set i_am_a_60 = 1 where (rand() <= 0.60);
create table foo_60 as select * from foo where i_am_a_60 = 1;
create table foo_40 as select * from foo where i_am_a_60 <> 1;
The CASE condition might be usable as well but I haven't puzzled it out ...
G
-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org on behalf of A. Kretschmer
Sent: Tue 10/17/2006 2:12 AM
To: pgsql-sql(at)postgresql(dot)org; pgsql-novice(at)postgresql(dot)org
Cc:
Subject: Re: [SQL] [GENERAL] How to split a table?
am Tue, dem 17.10.2006, um 1:53:35 -0700 mailte Gregory S. Williamson folgendes:
> Perhaps something like:
>
> CREATE TABLE foo2 AS SELECT * FROM foo WHERE (rand() <= 0.60);
Then we have 2 tables: one with 100% data and one with around 60% ;-)
If the table contains a primary key you can delete simple the copied
records from the origin table.
(delete from origin where pk in (select pk from copy);
>
> -----Original Message-----
Please, no top-posting with fullquote below.
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
-------------------------------------------------------
Click link below if it is SPAM gsw(at)globexplorer(dot)com
"https://mailscanner.globexplorer.com/dspam/dspam.cgi?signatureID=45349cb0275391789821027&user=gsw(at)globexplorer(dot)com&retrain=spam&template=history&history_page=1"
!DSPAM:45349cb0275391789821027!
-------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Christoph Frick | 2006-10-17 09:26:16 | Re: [NOVICE] How to split a table? |
Previous Message | A. Kretschmer | 2006-10-17 09:12:38 | Re: [SQL] [GENERAL] How to split a table? |
From | Date | Subject | |
---|---|---|---|
Next Message | Christoph Frick | 2006-10-17 09:26:16 | Re: [NOVICE] How to split a table? |
Previous Message | A. Kretschmer | 2006-10-17 09:12:38 | Re: [SQL] [GENERAL] How to split a table? |
From | Date | Subject | |
---|---|---|---|
Next Message | Christoph Frick | 2006-10-17 09:26:16 | Re: [NOVICE] How to split a table? |
Previous Message | A. Kretschmer | 2006-10-17 09:12:38 | Re: [SQL] [GENERAL] How to split a table? |