Re: Got error on CREATE TABLE AS (+Bug?)

Поиск
Список
Период
Сортировка
От Command Prompt, Inc.
Тема Re: Got error on CREATE TABLE AS (+Bug?)
Дата
Msg-id Pine.LNX.4.30.0111041525430.19169-100000@commandprompt.com
обсуждение исходный текст
Ответ на Got error on CREATE TABLE AS  ("Jeff Lu" <jklcom@mindspring.com>)
Ответы Re: Got error on CREATE TABLE AS (+Bug?)  ("Command Prompt, Inc." <pgsql-general@commandprompt.com>)
Re: Got error on CREATE TABLE AS (+Bug?)  ("Jeff Lu" <jklcom@mindspring.com>)
Список pgsql-general
On Sun, 4 Nov 2001, Jeff Lu wrote:
>Hi,
>I'm getting parser error at or near AS
>when try to copy a table using CREATE TABLE AS
>Here what I have in the sql statement
>CREATE TABLE employee_backup (id text UNIQUE, lastname text, firstname text,
>phone text) AS SELECT * FROM employee
>Can some body tell me what is wrong with the sql statement?

I don't believe you can specify types or constraints. Also, if you specify
the name of each column in parens, PostgreSQL seems to get confused if you
do a SELECT * following AS, rather than specify each table name as well
(as of 7.1.x, I get ERROR:  CREATE TABLE/AS SELECT has mismatched column
count - is this a known bug?)

I believe this should work, though you lose the UNIQUE constraint:

CREATE TABLE employee_backup AS SELECT * FROM employee;


Regards,
Jw.
--
jlx@commandprompt.com
by way of pgsql-general@commandprompt.com


В списке pgsql-general по дате отправления:

Предыдущее
От: "Aaron Rouse"
Дата:
Сообщение: Restoring data help
Следующее
От: "Command Prompt, Inc."
Дата:
Сообщение: Re: Got error on CREATE TABLE AS (+Bug?)