From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | "Matthew Schumacher" <matt(dot)s(at)aptalaska(dot)net> |
Cc: | "howachen(at)gmail(dot)com" <howachen(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: pgsql vs mysql |
Date: | 2006-06-30 21:08:40 |
Message-ID: | b42b73150606301408i19ea8101md205d46469fe0a08@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> Mysql does not allow you to use now() as the default value of a column.
> From their docs:
>
> "The DEFAULT clause specifies a default value for a column. With one
> exception, the default value must be a constant; it cannot be a function
> or an expression. This means, for example, that you cannot set the
> default for a date column to be the value of a function such as NOW() or
> CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as
> the default for a TIMESTAMP column. See Section 11.3.1.1, "TIMESTAMP
> Properties as of MySQL 4.1". "
>
> So they work around this major shortcoming by giving people the
> CURRENT_TIMESTAMP constant for the timestamp column so at least the
> people wanting an automatic timestamps are happy. Basically they add
> just enough support to do the most common thing.
>
> Postgres, allows all of the functions in a create table statement. This
> is legit in postgres:
>
> create table test_tab (data varchar(20), timestamp timestamp default
> now() - interval '32.56 minutes');
right mysql implementation of defaults is a complete disaster, a big
contributing factor as to why mysql tends to favor application code.
In contrast, pg follows the principle of least suprise, becuase the
internal structures are open and highly generic. the syntax is
standardized and regular (as much as with possible somehow) wherever
possible with carefully thought out exceptions.
mysql syntax, otoh, is hacky and full of special cases. each basic
sql command is highly nuanced and full of legacy workarounds to
limitations of previous versions of mysql. some of the specific
commands (insert, especially) are quite powerful but the whole adds up
to less than the sum of its parts somehow.
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Browne | 2006-06-30 21:34:40 | Re: Notes on converting from MySQL 5.0.x to PostgreSQL |
Previous Message | a | 2006-06-30 21:00:38 | db question - dynamic fields in db |