Search Postgresql Archives

Re: [NOVICE] How to split a table?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx [mailto:pgsql-novice-owner@xxxxxxxxxxxxxx] On Behalf Of Felix Zhang
Sent: Tuesday, October 17, 2006 3:39 AM
To: pgsql-sql@xxxxxxxxxxxxxx; pgsql-general@xxxxxxxxxxxxxx; pgsql-novice@xxxxxxxxxxxxxx
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.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux