Re: A couple of newbie questions ...

Поиск
Список
Период
Сортировка
От John DeSoi
Тема Re: A couple of newbie questions ...
Дата
Msg-id 34DBDC21-DBCD-4A39-AC05-BEFA9629DB50@pgedit.com
обсуждение исходный текст
Ответ на Re: A couple of newbie questions ...  (Shane Ambler <pgsql@Sheeky.Biz>)
Список pgsql-general
On Jul 23, 2008, at 12:00 PM, Shane Ambler wrote:

> To be honest I hadn't seen the use of INSERT INTO table (fld_x,
> fld_y,fld_z) VALUES (DEFAULT, 'y','z') before, I have always gone
> with INSERT INTO table (fld_x, fld_y,fld_z) VALUES (NULL, 'y','z')
>
> is DEFAULT a better option than using NULL? or is it just a
> preference to spell out the implied default entry?
>
> I've only used DEFAULT in CREATE TABLE(...)

The semantics of using DEFAULT or NULL is completely different. If the
column has a default value (for example, 0), then including DEFAULT in
your insert list will give you the default value of zero. But if you
include NULL in your insert list -- you'll get NULL, not zero. If
nothing is included for the column in your insert list, you'll get the
column default if it has one, otherwise NULL.


John DeSoi, Ph.D.





В списке pgsql-general по дате отправления:

Предыдущее
От: Alex Cheshev
Дата:
Сообщение: Sequence
Следующее
От: admin
Дата:
Сообщение: Re: php + postgresql