Re: [GENERAL] More newbie question: Restructuring a table

From: Karel Zak - Zakkr <zakkr(at)zf(dot)jcu(dot)cz>
To: Timothy Grant <tjg(at)avalongroup(dot)net>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] More newbie question: Restructuring a table
Date: 2000-03-01 22:10:30
Message-ID: Pine.LNX.3.96.1000301230614.14720A-100000@ara.zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Wed, 1 Mar 2000, Timothy Grant wrote:

> Hi again,
>
> Is there a quick and dirty way that I am missing for creating a new
> database with a slightly different schema than the old db?
>
> For example, I have a table with a DATETIME field that I really need to
> change to a DATE field.
>
> I can create a new table with that field defined as a DATE, but if I do
> the following:
>
> INSERT INTO newtable SELECT * FROM oldtable;
>

Example:

SELECT column1, column2::date, column3 INTO newtable FROM oldtable;

- where column2 is a column with your not wanted datetime and is changed to
date. You must cast to new type from old type.
Karel

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Timothy Grant 2000-03-01 22:31:08 PostgreSQL ODBC and Crystal Reports
Previous Message Timothy Grant 2000-03-01 21:55:06 More newbie question: Restructuring a table