Re: I was spoiled by the MySQL timestamp field - Mailing list pgsql-general

From Matthew Nuzum
Subject Re: I was spoiled by the MySQL timestamp field
Date
Msg-id 001401c2c31a$605870d0$6700a8c0@mattspc
Whole thread Raw
In response to Re: I was spoiled by the MySQL timestamp field  (Björn Metzdorf <bm@turtle-entertainment.de>)
Responses Re: I was spoiled by the MySQL timestamp field
Re: I was spoiled by the MySQL timestamp field
List pgsql-general
One word of caution, I *think* you want quotes around the 'now()'
statement in your table definition. Otherwise your default value will be
the instant the *table* was created, not the instant your insert
happened.

I too had an adjustment period when switching from MySQL to postgres.
However, I think you'll find that if you use a RULE to implement this
feature you will soon become addicted to PostgreSQL's advanced feature
set.

You can learn more about rules by going to
http://www.ca.postgresql.org/docs/aw_pgsql_book/node124.html where you
can find a brief description and example, or for more detail, you can go
to
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/rules-insert
.html

I attained all of my database knowledge through hands on experience;
much of it on MySQL.  Switching to PostgreSQL was somewhat traumatic
because it has a lot more power and a lot more features.  Once I got a
handle on things like Views, Triggers and Rules, I have become somewhat
dependant on them and I haven't been able to use MySQL for anything more
than the most basic of applications.  I guess that's just a warning...
There may be no turning back.

--
Matthew Nuzum
www.bearfruit.org
cobalt@bearfruit.org


> -----Original Message-----
> From: Björn Metzdorf [mailto:bm@turtle-entertainment.de]
> Sent: Thursday, January 23, 2003 7:32 AM
> To: Alan T. Miller; pgsql-general@postgresql.org
> Subject: Re: I was spoiled by the MySQL timestamp field
>
> > As someone who is just getting started with PostygreSQL from years
> working
> > with MySQL, it appears that the timestamp data type does not behave
in
> the
> > way it did with MySQL. I got used to just defining a column as a
> timestamp
> > and letting the database throw the latest time stamp in there
whenever a
> row
> > was updated. Is there anything simular in PosgreSQL? How can I
> accomplish
> > something simular inside the database, or am I stuck populating the
> field
> in
> > some manner as in the following example
>
> There is no such datatype in postgresql. If you just need the current
time
> inserted on INSERT and not on UPDATE, then you can declare that column
> with
> "default now()". Else you will need to install a trigger, then you can
> have
> exactly the same behaviour as with mysql.
>
> Regards,
> Bjoern



pgsql-general by date:

Previous
From: Maciej Fuchs
Date:
Subject: Problem with plpgsql TRIGGER
Next
From: "codeWarrior"
Date:
Subject: Re: I was spoiled by the MySQL timestamp field