Re: pgsql vs mysql - Mailing list pgsql-general

From Merlin Moncure
Subject Re: pgsql vs mysql
Date
Msg-id b42b73150606301408i19ea8101md205d46469fe0a08@mail.gmail.com
Whole thread Raw
In response to Re: pgsql vs mysql  (Matthew Schumacher <matt.s@aptalaska.net>)
List 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.

pgsql-general by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: join on next row
Next
From: Chris Browne
Date:
Subject: Re: Notes on converting from MySQL 5.0.x to PostgreSQL