Re: import and foreign keys

From: Richard Seymour <rseymour(at)anarchysoftware(dot)com>
To: "Thomas T(dot) Thai" <tom(at)minnesota(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: import and foreign keys
Date: 2001-01-24 11:05:26
Message-ID: 3A6EB6F6.4888524@anarchysoftware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If you build your strucutres as you've shown (explicitely creating your
sequences), and then import, you shouldn't have any problem, with one
caveat. You'll need to determine the hightest current key for each table
and start your sequence accordingly. To start a squence at 500:

> CREATE SEQUENCE "next_url_id" start 500 increment 1 maxvalue 2147483647

"Thomas T. Thai" wrote:
>
> i'm in the process of importing my data from my existing db (mysql) to
> pgsql. one thing i'm confused about is the use of foreign keys. in my
> existing db, i use the foreign keys to relate from one table to the
> next. it's a forum type application. the key is based on an auto-increment
> field.
>
...
> i'm wondering what will happen to that field if i import into pgsql? will
> pgsql figure out what the last highest id is and continue from
> there? assuming i've defined my table structures properly using:
>
> CREATE SEQUENCE "next_url_id" start 1 increment 1 maxvalue 2147483647
>
> CREATE TABLE "url" (
> "rec_id" integer DEFAULT nextval('next_url_id'::text) NOT NULL,
> ...

--
Richard Seymour : Anarchy Software, Inc.
- * - - * - - - * -+- * - - - * - - * -
`°º¤ø,¸ ¸,ø¤º°'
`°º¤ø,¸¸,ø¤º°

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Zak McGregor 2001-01-24 11:06:30 Re: Re: MySQL has transactions
Previous Message Kogotkov, Vyacheslav 2001-01-24 10:59:20 Can't connect to anonCVS !