EXT-Rothermel, Peter M wrote:
I have a table where I would like the primary key to be generated during
the insert.
Here is a simplified example:
CREATE TABLE employee_type
{
tname varchar(10) PRIMARY KEY,
id_prefix char(1) ;
...
}
tname | id_prefix
--+--
On Thursday 06 November 2008, "EXT-Rothermel, Peter M"
<[EMAIL PROTECTED]> wrote:
> I have thought about using the serial data type for the employee.id but
> I also want to automate the prepending of the { W, M, E } prefix.
>
You'll need write a before-insert trigger to assign the ID.
--
Alan
"Adam Rich" <[EMAIL PROTECTED]> writes:
>> I have just created a table using SELECT INTO however the PK was
>> supposed to be a serial. It is now an integer. To make it a serial I
>> just create the seq and set the default to be the nextval() of that
>> sequence right? is there anything else I need
On Wed, Apr 2, 2008 at 10:12 PM, Naz Gassiep <[EMAIL PROTECTED]> wrote:
> I have just created a table using SELECT INTO however the PK was
> supposed to be a serial. It is now an integer. To make it a serial I
> just create the seq and set the default to be the nextval() of that
> sequence right
> I have just created a table using SELECT INTO however the PK was
> supposed to be a serial. It is now an integer. To make it a serial I
> just create the seq and set the default to be the nextval() of that
> sequence right? is there anything else I need to do?
You'll want to do this:
ALTER SE
Joseph Healy <[EMAIL PROTECTED]> writes:
> On Sat, Sep 25, 2004 at 07:20:23PM -0400, Tom Allison wrote:
>>
>> Any idea how to set up a timestamp=now on every insert/update ?
>
> when you create your table, use:
>
> create table mytable (
> id serial primary key,
> updated timestamp d
On Sat, Sep 25, 2004 at 07:20:23PM -0400, Tom Allison wrote:
>
> Any idea how to set up a timestamp=now on every insert/update ?
when you create your table, use:
create table mytable (
id serial primary key,
updated timestamp default(now()),
mydata int4
);
Joe
-
Tom Allison <[EMAIL PROTECTED]> writes:
> Doug McNaught wrote:
>>>Is it realistic to use the serial data type as a KEY?
>> Lots and lots of people do. If you're just looking for a unique key
>> column for a single table, it works fine.
>> -Doug
>
> This is essentially what I'm looking for.
>
> An
Doug McNaught wrote:
Is it realistic to use the serial data type as a KEY?
Lots and lots of people do. If you're just looking for a unique key
column for a single table, it works fine.
-Doug
This is essentially what I'm looking for.
Any idea how to set up a timestamp=now on every insert/update ?
Tom Allison <[EMAIL PROTECTED]> writes:
> Can I use the serial data type in lieu of an 'auto_number' field?
What are the exact semantics of an "auto_number" field?
> I asked something like this some months ago and it seems that
> auto_number fields were addressed through a combination of trigger
10 matches
Mail list logo