Re: [GENERAL] [NOVICE] How to split a table?

2006-10-17 Thread Obe, Regina



I would do
 
select * into mynewtable 
from myoldtable ORDER by random() LIMIT 15000
 
where 15000 in this case is *.6
 
If you want to create another table with 40% of the 
remaining data then something like
 
select * into mynewtable2 from myoldtable where 
myoldtable.primarykey NOT IN(select primarykey from 
mynewtable)
]
In this case primarykey you would replace with the 
primary key field of your table.


From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of Felix 
ZhangSent: Tuesday, October 17, 2006 3:39 AMTo: 
pgsql-sql@postgresql.org; pgsql-general@postgresql.org; 
[EMAIL PROTECTED]Subject: [NOVICE] 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




The substance of this message, including any attachments, may be
confidential, legally
privileged and/or exempt from disclosure pursuant to Massachusetts
law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and
delete the material from any computer.



Re: [GENERAL] [NOVICE] How to split a table?

2006-10-17 Thread Christoph Frick
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


pgpHaMIrIiAlt.pgp
Description: PGP signature