| From: | Shadkam Islam <shadkam(at)wipinfo(dot)soft(dot)net> | 
|---|---|
| To: | Stuart Rison <rison(at)biochemistry(dot)ucl(dot)ac(dot)uk> | 
| Cc: | "Michal A(dot) Kowalski" <mak(at)minfo(dot)com(dot)pl>, pgsql-general(at)postgreSQL(dot)org | 
| Subject: | Re: [GENERAL] Change table structure. | 
| Date: | 1999-09-23 15:53:18 | 
| Message-ID: | Pine.LNX.3.96.990923211842.11913B-100000@trishul.wipinfo.soft.net | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
Just to add to it...
If you want to drop a column and you do not want to lose data from the
table you may follow the following sequence,
select field1,field2... from TableToBeChanged
into TableToBeChanged_OldData;
where field1,field2... will be having all the columns except the one you
want to delete.
Once it is done you can drop the TableToBeChanged, 
and rename TableToBeChanged_OldData to TableToBeChanged.
Hope it helps...
-Cheers,
-Shad.
On Thu, 23 Sep 1999, Stuart Rison wrote:
> AFAIK, you can add and and rename columns no problem:
> 
> functions=> \h alter table
> Command: alter table
> Description: add/rename attributes, rename tables
> Syntax:
>         ALTER TABLE class_name [*] ADD COLUMN attr type
>         ALTER TABLE class_name [*] RENAME [COLUMN] attr1 TO attr2
>         ALTER TABLE class_name1 RENAME TO class_name2
> 
> But you can't drop a column without a DROP and CREATE again.
> 
> 
> 
> On Thu, 23 Sep 1999, Michal A. Kowalski wrote:
> 
> > Hi,
> > 
> > is there any way to change table structure without doing DROP and CREATE
> > again?
> > 
> > Regards,
> > MAK.
> > ___________________________________________________________________________
> > --  Michal A. Kowalski  --  http://www.minfo.com.pl -- mak(at)minfo(dot)com(dot)pl  --
> > 
> > ************
> > 
> 
> Stuart C. G. Rison
> Department of Biochemistry and Molecular Biology
> 6th floor, Darwin Building, University College London (UCL)
> Gower Street, London, WC1E 6BT, United Kingdom
> Tel. 0207 504 2303, Fax. 0207 380 7033
> e-mail: rison(at)biochem(dot)ucl(dot)ac(dot)uk
> 
> 
> ************
> 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Sebestyen Zoltan | 1999-09-23 16:02:49 | 6.4.2->6.5.2 migration problem.. | 
| Previous Message | amy cheng | 1999-09-23 15:49:47 | Re: [GENERAL] data mart indexing support? |