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

Поиск
Список
Период
Сортировка
От Karel Zak - Zakkr
Тема Re: [GENERAL] More newbie question: Restructuring a table
Дата
Msg-id Pine.LNX.3.96.1000301230614.14720A-100000@ara.zf.jcu.cz
обсуждение исходный текст
Ответ на More newbie question: Restructuring a table  (Timothy Grant <tjg@avalongroup.net>)
Список 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 по дате отправления:

Предыдущее
От: Timothy Grant
Дата:
Сообщение: More newbie question: Restructuring a table
Следующее
От: Timothy Grant
Дата:
Сообщение: PostgreSQL ODBC and Crystal Reports