From: | "Obe, Regina" <robe(dot)dnd(at)cityofboston(dot)gov> |
---|---|
To: | "Felix Zhang" <felix(dot)zhang(dot)2005(at)gmail(dot)com>, <pgsql-sql(at)postgresql(dot)org>, <pgsql-general(at)postgresql(dot)org>, <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: [NOVICE] How to split a table? |
Date: | 2006-10-17 10:54:55 |
Message-ID: | 53F9CF533E1AA14EA1F8C5C08ABC08D201044B3D@ZDND.DND.boston.cob |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice pgsql-sql |
I would do
select * into mynewtable from myoldtable ORDER by random() LIMIT 15000
where 15000 in this case is <your table row count>*.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: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org] On Behalf Of Felix Zhang
Sent: Tuesday, October 17, 2006 3:39 AM
To: pgsql-sql(at)postgresql(dot)org; pgsql-general(at)postgresql(dot)org;
pgsql-novice(at)postgresql(dot)org
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Stefan Sassenberg | 2006-10-17 11:12:00 | ERRORDATA_STACK_SIZE exceeded |
Previous Message | Jorge Godoy | 2006-10-17 10:51:49 | Re: [SQL] [GENERAL] How to split a table? |
From | Date | Subject | |
---|---|---|---|
Next Message | Sean Davis | 2006-10-17 11:47:59 | could not write to hash-join temporary file: No space left on device |
Previous Message | Jorge Godoy | 2006-10-17 10:51:49 | Re: [SQL] [GENERAL] How to split a table? |
From | Date | Subject | |
---|---|---|---|
Next Message | Achilleas Mantzios | 2006-10-17 11:08:44 | Fwd: Re: [GENERAL] How to split a table? |
Previous Message | Jorge Godoy | 2006-10-17 10:51:49 | Re: [SQL] [GENERAL] How to split a table? |