Re: Foreign key pg_dump issue and serial column type

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Foreign key pg_dump issue and serial column type
Дата
Msg-id 1391.1120094146@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Foreign key pg_dump issue and serial column type  ("Vsevolod (Simon) Ilyushchenko" <simonf@cshl.edu>)
Список pgsql-sql
"Vsevolod (Simon) Ilyushchenko" <simonf@cshl.edu> writes:
> However, when I pg_dump the database and import it on another server, 
> the tables are exported alphabetically, so when the 'people_roles' table 
> is created with its foreign keys, the table 'roles' does not exist yet. 
> Thus, the foreign key creation fails. Is there a way around it?

Are you sure you are using 8.0 pg_dump?  That's a longstanding
deficiency in older versions, but 8.0 is not supposed to have a problem
with it.  If you're sure it's an up-to-date pg_dump, could you provide a
complete test case (ie, a script to create a database that pg_dump has
trouble with)?

> 2. I've just discovered the 'serial' column type and tried to do this:
> alter table people_roles alter column  people_roles_code type serial;
> To my surprise, it fails:
> ERROR:  type "serial" does not exist

Serial isn't quite a true type, and so it doesn't work in every context
that you might think.  It'd probably make sense for "alter column type"
to accept it, but for now what you gotta do is create a sequence
and set the column default manually.
        regards, tom lane


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

Предыдущее
От: "Vsevolod (Simon) Ilyushchenko"
Дата:
Сообщение: Foreign key pg_dump issue and serial column type
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Error saving image to PostgresSQL 8.x database