pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Ansley <Michael.Ansley@intec-telecom-systems.com>
To: 'Diehl, Jeffrey ' <jdiehl@sandia.gov>
To: 'pgsql-sql@postgresql.org ' <pgsql-sql@postgresql.org>
Subject: RE: DB porting questions...
Date: Thu, 12 Apr 2001 00:29:11 +0100
Message-ID: <7F124BC48D56D411812500D0B747251480F522@fileserver002.intecsystems.co.uk> (raw)

Hi, Jeff,
 

>>  1)
>>  I have a table:
>>  	create table a (
>>  		t	timestamp not null,
>>  		...
>>  	);
>>  
>>  I'm thinking that I can define a.t as not null default=now().  But >>
will
>>  this
>>  work?  That is, will it update a.t when I modified a given record?
You need to set the default, but you have to use now() in (single) quotes,
otherwise all records will use the time that the CREATE statement was
executed:
t timestamp not null default 'now()',
...or something close.  It's in the docs somewhere too.

>>  2)
>>  I have another table:
>>  	create table b (
>>  		id	int not null AUTO_INCREMENT,
>>  		...	
>>  	);
>>  
>>  To reproduce this behavior, I believe I need to use a sequence.  The
>>  problem
>>  is that I have a lot of data to import into this table.  How do I 
>>  import the old data without colliding with the new sequence numbers?
What you do is create the id column of type SERIAL, then import your data,
and then immediately afterwards, use setval() to update the current value of
the sequence to one more than the highest value that you imported.  The
syntax for setval() is in the docs.  During the import of your data, the
sequence will not be used for incrementing the id, as it's only used as the
default, not if you actually provide a value.

Cheers...


MikeA




_________________________________________________________________________
This e-mail and any attachments are confidential and may also be privileged and/or copyright 
material of Intec Telecom Systems PLC (or its affiliated companies).  If you are not an 
intended or authorised recipient of this e-mail or have received it in error, please delete 
it immediately and notify the sender by e-mail.  In such a case, reading, reproducing, 
printing or further dissemination of this e-mail is strictly prohibited and may be unlawful. 
Intec Telecom Systems PLC. does not represent or warrant that an attachment hereto is free 
from computer viruses or other defects. The opinions expressed in this e-mail and any 
attachments may be those of the author and are not necessarily those of Intec Telecom 
Systems PLC. 

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses. 
__________________________________________________________________________

view thread (11+ messages)  latest in thread

Message-ID: <7F124BC48D56D411812500D0B747251480F522@fileserver002.intecsystems.co.uk>
Permalink:  ../7F124BC48D56D411812500D0B747251480F522@fileserver002.intecsystems.co.uk/
Also on:    postgresql.org/message-id/7F124BC48D56D411812500D0B747251480F522@fileserver002.intecsystems.co.uk

 · 

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-sql@postgresql.org
  Cc: Michael.Ansley@intec-telecom-systems.com, jdiehl@sandia.gov
  Subject: Re: DB porting questions...
  In-Reply-To: <7F124BC48D56D411812500D0B747251480F522@fileserver002.intecsystems.co.uk>
  References: <7F124BC48D56D411812500D0B747251480F522@fileserver002.intecsystems.co.uk>

* 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