Re: pgsql vs mysql
От | Merlin Moncure |
---|---|
Тема | Re: pgsql vs mysql |
Дата | |
Msg-id | b42b73150606301408i19ea8101md205d46469fe0a08@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: pgsql vs mysql (Matthew Schumacher <matt.s@aptalaska.net>) |
Список | 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 по дате отправления: