From: | "Matthew Nuzum" <cobalt(at)bearfruit(dot)org> |
---|---|
To: | 'Björn Metzdorf' <bm(at)turtle-entertainment(dot)de>, "'Alan T(dot) Miller'" <amiller(at)hollywood101(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: I was spoiled by the MySQL timestamp field |
Date: | 2003-01-23 20:02:33 |
Message-ID: | 001401c2c31a$605870d0$6700a8c0@mattspc |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)bearfruit(dot)org
> -----Original Message-----
> From: Björn Metzdorf [mailto:bm(at)turtle-entertainment(dot)de]
> Sent: Thursday, January 23, 2003 7:32 AM
> To: Alan T. Miller; pgsql-general(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | will trillich | 2003-01-23 20:20:43 | Re: HOW-TO do incomplete dates: year, optional month, optional day? |
Previous Message | Matthew Nuzum | 2003-01-23 19:51:50 | Re: PHP Abstraction Layer - Your Opinion Please |