From: | davidb(at)vectormath(dot)com |
---|---|
To: | "Richard Smith" <ozric(at)tampabay(dot)rr(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: beginner Table data type question |
Date: | 2000-05-19 17:40:05 |
Message-ID: | 002401bfc1b9$471719b0$0602010a@bullwinkle.vectormath |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Richard,
For constraints see:
http://www.postgresql.org/doxlist.html
then select Documentation
then select Integrated Document
then select Alter Table
For Column definitions:
I believe some other implementations of SQL allow you to alter
columns as long as you are keeping the same basic datatype and
increasing the size, but require a copy-drop-add-copy if you are
changing the basic datatype or decreasing the size.
Postgres requires a copy-drop-add-copy for any change to column
definitions.
David Boerwinkle
-----Original Message-----
From: Richard Smith <ozric(at)tampabay(dot)rr(dot)com>
To: pgsql-general(at)postgresql(dot)org(dot)pgsql-questions@postgreSQL.org
<pgsql-general(at)postgresql(dot)org(dot)pgsql-questions@postgreSQL.org>
Date: Friday, May 19, 2000 11:12 AM
Subject: [GENERAL] beginner Table data type question
>Hi, I just start using pgsql and I am new to SQL also. I have read lots
>of
>documents on this and I cant seem to find the answer, perhaps you can
>help me.
>
>Say I have a table:
>
>pgsql=> \d test_table
>
>test_table
>------------------------------
>f1| CHAR (40)
>f2| CHAR (40)
>
>Somewhere down the line I need to change the data type on f2 to CHAR
>(50) and add constrains like UNIQUE. What is the best was to change
>tables in this way?
>Can I just make a new table the way I want and COPY the data out of the
>old table and COPY it back in? do I use CAST ? Is there some ALTER
>TABLE tablename MODIFY command I can use?
>
>This question has been bugging me for awhile. Because I am new to SQL I
>find that I make bad design choices about data types and such all the
>time. So I need to know the best way to change them.
>
>Richard
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2000-05-19 17:56:58 | Re: Performance (was: The New Slashdot Setup (includes MySql server)) |
Previous Message | Tom Lane | 2000-05-19 17:36:29 | Re: Performance (was: The New Slashdot Setup (includes MySql server)) |