Click to See Complete Forum and Search --> : PostgreSQL


tminos
11-07-2000, 03:31 PM
While making a table in a PostgreSQL database, I believe I made one field waaay too big. What I want to do is make the field (in this case, name) to be something like 20 chars wide instead of 50. In a book I have it says to use
alter table <name>
change name
name varchar(20);

and that would fix it, but PostgreSQL doesn't like the "change" command. Any ideas?

klamath
11-07-2000, 05:30 PM
You can't currently do that in Postgres (it would have some strange effects, too - what if a field is longer than 20 chars? What if a user tries to change a 'char(20)' field to 'timestamp' or something like that?).

One possible solution it to use SELECT ... INTO [table] to "dump" the data from the first table into a new one with the correct schema.

------------------
- Klamath
Get my GnuPG Key Here (http://klamath.dyndns.org/mykey.asc)
Looking for an open source project to contribute to? Check out the BBB (http://bbb.sourceforge.net)

tminos
11-08-2000, 01:33 AM
Bump.

Thanks, I'll try that.