Changing a table space?

PostgreSQL is the database server used to store information. Do you have a question or are you having problem with PostgreSQL? If so, post them here.

Moderator: Moderators

Changing a table space?

Postby MrFlibble » Fri May 09, 2008 8:20 am

Has anyone ever changed the table space of a PT table to a table space on another drive? It it as simple as running the command to move it and postgres will then copy over the table and you continue life as normal?
MrFlibble
 
Posts: 58
Joined: Sat Mar 08, 2008 7:30 pm
Location: handhq.com for datamined hands

Re: Changing a table space?

Postby _dave_ » Fri May 09, 2008 5:15 pm

I can't remember if it is possible to re-assign tablespace after creation... is it? if so, what is the command?

I've certainly changed the tablespaces of various tables before I created the database - you just edit the schema.sql file, adding tablespace commands after all the create table sections.

I've yet to figure out "optimal", but I do like moving the lookup_* tables on to a little ramdisk, that's gotta speed things up (never actually benchmarked to see how much) and since they never change those are easily rebuilt on boot :)
_dave_
 
Posts: 1147
Joined: Sun Dec 09, 2007 6:19 pm

Re: Changing a table space?

Postby MrFlibble » Sat May 10, 2008 9:50 am

I think its just
ALTER TABLE my_table SET TABLESPACE new_tablespace
I haven't tried it yet...
MrFlibble
 
Posts: 58
Joined: Sat Mar 08, 2008 7:30 pm
Location: handhq.com for datamined hands

Re: Changing a table space?

Postby APerfect10 » Sat May 10, 2008 12:07 pm

ALTER TABLESPACE

Best regards,

Derek
APerfect10
Site Admin
 
Posts: 4489
Joined: Sat Dec 08, 2007 6:03 pm

Re: Changing a table space?

Postby MrFlibble » Sat May 10, 2008 12:38 pm

APerfect10 wrote:ALTER TABLESPACE
Best regards,
Derek

I think that pertains to changing the details of an existing table space. I'm looking to make some or all of the PT DB tables use a different tablespace. I think the command in my last post will do it.
MrFlibble
 
Posts: 58
Joined: Sat Mar 08, 2008 7:30 pm
Location: handhq.com for datamined hands

Re: Changing a table space?

Postby _dave_ » Sat May 10, 2008 1:45 pm

MrFlibble wrote:I think its just
ALTER TABLE my_table SET TABLESPACE new_tablespace
I haven't tried it yet...


Looks like the job :)
http://www.postgresql.org/docs/8.3/inte ... table.html
SET TABLESPACE

This form changes the table's tablespace to the specified tablespace and moves the data file(s) associated with the table to the new tablespace. Indexes on the table, if any, are not moved; but they can be moved separately with additional SET TABLESPACE commands.


Still looks a bit of a pain if you are planning to move a whole database - much easier to use the "CREATE DATABASE xxx TABLESPACE xxx" method I posted here, import the schema.sql file, then all tables / indexes etc are on the alternate tablespace in two commands.

The ALTER DATABASE command doesn't seem to be able to set tablespaces after a quick read :(
_dave_
 
Posts: 1147
Joined: Sun Dec 09, 2007 6:19 pm

Re: Changing a table space?

Postby MrFlibble » Sat May 10, 2008 1:59 pm

_dave_ wrote: - much easier to use the "CREATE DATABASE xxx TABLESPACE xxx" method I posted here, import the schema.sql file, then all tables / indexes etc are on the alternate tablespace in two commands.

The ALTER DATABASE command doesn't seem to be able to set tablespaces after a quick read :(

Ah excellent. I couldn't think of a way to create a PT DB on a non default namespace.
MrFlibble
 
Posts: 58
Joined: Sat Mar 08, 2008 7:30 pm
Location: handhq.com for datamined hands


Return to PostgreSQL [Read Only]

Who is online

Users browsing this forum: No registered users and 9 guests