pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lane Van Ingen <lvaningen@esncc.com>
To: giuseppe.derossi@email.it
To: pgsql-admin@postgresql.org
Subject: Re: trobles in importing dbf file
Date: Thu, 11 May 2006 07:54:58 -0400
Message-ID: <EKEMKEFLOMKDDLIALABICELDCKAA.lvaningen@esncc.com> (raw)
In-Reply-To: <0dacdc79dc4a12f8ff5b8ac7a4d7566e@164.129.1.39>

I use 8.0.7; PostgreSQL will create tables with the number of a row (called
an OID) automatically if the config parameter called default_with_oids in
postgres.conf file is set to true. If not, it will do what your CREATE TABLE
statement says (WITH OIDS or WITHOUT OIDS); here is a sample:
  CREATE TABLE alarm_active (
  alarmtypeid integer NOT NULL default '0',
  alarmsource integer NOT NULL default '0',
  alarmstateid integer NOT NULL default '0',
  messageid integer NOT NULL default '0',
  ackby varchar(30) default NULL,
  silencedby varchar(30) default NULL,
  updatedtime timestamp(3) NOT NULL default current_timestamp(3),
  alarmrfid integer NOT NULL default '0',
  CONSTRAINT alarm_active_pk PRIMARY KEY (alarmtypeid,alarmsource)
) WITH OIDS;

You asked about PRIMARY KEYS. There is an example of that above, too. You
can also use ALTER TABLE to add a primary key.

I have never used dbf2pg.exe so I don't know what it adds or substracts from
the conversion process. But if it doesn't take care of the above for you, I
suppose what you could do is:
  - do your import;
  - set up the new table with another name, the way you want it;
  - INSERT into the new table from the table that got set up by db2pg.exe
  - drop the old table
  - rename the new table to the old table name by using
      ALTER TABLE <new table> RENAME TO <old table>

-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org]On Behalf Of
giuseppe.derossi@email.it
Sent: Thursday, May 11, 2006 3:25 AM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] trobles in importing dbf file


Hi Guys,
I'm a newbie in Postgres and hope my mail is not off topic. Well, I'm
migrating from Mysql to PostGree in order to use the postgis features. I've
some dbf files I've to import, so I've used the utility dbf2pg.exe ( I've
installed the version 8.1 in win xp env). Now is there a way to add
automatically a primary key  if no, how
can I can add it after importing the table in postgres ? In mYsql an index
(the number or row) is automatically added as first column.
Sorry if the question is trivial, I didn't suspect this gap.
Is there a standard proceure to import a database mapped in a lot of dbf
files.




Thanks in advantage

 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f

 Sponsor:
 Partecipa al concorso Best Western, ogni giorno puoi vincere un fantastico
week end da sogno!
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=5096&d=20060511



---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend





view thread (5+ messages)  latest in thread

Message-ID: <EKEMKEFLOMKDDLIALABICELDCKAA.lvaningen@esncc.com>
Permalink:  ../EKEMKEFLOMKDDLIALABICELDCKAA.lvaningen@esncc.com/
Also on:    postgresql.org/message-id/EKEMKEFLOMKDDLIALABICELDCKAA.lvaningen@esncc.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: lvaningen@esncc.com, giuseppe.derossi@email.it
  Subject: Re: trobles in importing dbf file
  In-Reply-To: <EKEMKEFLOMKDDLIALABICELDCKAA.lvaningen@esncc.com>
  References: <0dacdc79dc4a12f8ff5b8ac7a4d7566e@164.129.1.39> <EKEMKEFLOMKDDLIALABICELDCKAA.lvaningen@esncc.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox