Re: [GENERAL] More newbie question: Restructuring a table - Mailing list pgsql-general

From Karel Zak - Zakkr
Subject Re: [GENERAL] More newbie question: Restructuring a table
Date
Msg-id Pine.LNX.3.96.1000301230614.14720A-100000@ara.zf.jcu.cz
Whole thread Raw
In response to More newbie question: Restructuring a table  (Timothy Grant <tjg@avalongroup.net>)
List 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



pgsql-general by date:

Previous
From: Timothy Grant
Date:
Subject: More newbie question: Restructuring a table
Next
From: Timothy Grant
Date:
Subject: PostgreSQL ODBC and Crystal Reports