Re: change existing table definition
От | Lee Wu |
---|---|
Тема | Re: change existing table definition |
Дата | |
Msg-id | E1F0E4D89D8FA44789DFC065C8E755281A364B@mxlhq-exch01.corp.mxlogic.com обсуждение исходный текст |
Ответ на | change existing table definition (Chuming Chen <chen@musc.edu>) |
Список | pgsql-admin |
In PG 7, you can add column like: create table test (c1 varchar(30)); alter table test add column c2 int; select version(); version ------------------------------------------------------------- PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.96 (1 row) I do not know you can alter field/column length in PG 8 and it can be done in PG 8: select version(); version ------------------------------------------------------------------------ ---------------------------------- PostgreSQL 8.0.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-49) (1 row) alter table test alter c1 type varchar(50); I think in PG, you can: 1. add a new right length column like shown 2. update test set new_column=old_column; 3. alter table drop old_column -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Chuming Chen Sent: Tuesday, June 28, 2005 8:40 AM To: Peter Eisentraut Cc: pgsql-admin@postgresql.org Subject: Re: [ADMIN] change existing table definition Peter Eisentraut wrote: >Chuming Chen wrote: > > >>How can I change the column definition of an existing table, ie. from >>varchar(30) to varchar(50)? Is there any way to add a new column to >>an existing table? >> >> > >The ALTER TABLE command can do all that. You need version 8.0 or later >for some functionality though. > > > Is there another way to do it in 7.* ? ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
В списке pgsql-admin по дате отправления: