From: | Michael Ansley <Michael(dot)Ansley(at)intec-telecom-systems(dot)com> |
---|---|
To: | "'Diehl, Jeffrey '" <jdiehl(at)sandia(dot)gov>, "'pgsql-sql(at)postgresql(dot)org '" <pgsql-sql(at)postgresql(dot)org> |
Subject: | RE: DB porting questions... |
Date: | 2001-04-11 23:29:11 |
Message-ID: | 7F124BC48D56D411812500D0B747251480F522@fileserver002.intecsystems.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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.
__________________________________________________________________________
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2001-04-11 23:29:48 | Re: DB porting questions... |
Previous Message | Diehl, Jeffrey | 2001-04-11 23:02:06 | DB porting questions... |