create table defaults...

Поиск
Список
Период
Сортировка
От Thomas O'Dowd
Тема create table defaults...
Дата
Msg-id 20000413195021.X30581@garman.uwillsee.com
обсуждение исходный текст
Список pgsql-general
Hi,

I'm new here. I'm developing a JAVA app to access a database
on linux and was using DB2 up to yesterday when I had to stop
using it because it didn't support threads on the linux version.
I plugged postgresql in and it pretty much worked with some
syntax changes... Couple of things that I'm confused about
though mostly concerning column defaults in create table.

I'm using v6.5.3 by the way.

For example...

    create table mytable (
    mydate date default now()::date
    );

but I keep getting the error

    ERROR:  parser: parse error at or near "now"

Using the following works but I believe keeps the date
of the table time and not the date of insert...

    mydate date default 'today'

I also have trouble using a CHECK on a NULL column.
Here is an example.

    create table mytable (
    name    varchar(10),
    option    char(1)    check (option in ('a','b'))
    );

This works okay as a defination, but when I do an
insert which can leave the option column NULL (which is
what I want) it doesn't work. I'm not sure if that is
correct behaviour or not but db2 used to work before
I had to stop using it. Here is the insert that will break it...

    insert into mytable (name) values ('tom');

I'm no SQL pro as it has been years since I've had to
do any, so my syntax maybe the problem, but I did try
and look things up before posting.

Cheers,

Tom.
--
Thomas O'Dowd
tom@uwillsee.com

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

Предыдущее
От: "Oliver Elphick"
Дата:
Сообщение: Re: Character encodings...
Следующее
От: Oleg Broytmann
Дата:
Сообщение: Re: Character encodings...