Adding a column with constraint

Поиск
Список
Период
Сортировка
Искать
От
Alexander Farber
Тема
Adding a column with constraint
Дата
Msg-id
AANLkTi=FcLm-EgChqm6aPT_q_ns04PF9vFqsUtrsLNNq@mail.gmail.com
Список
Дерево обсуждения
Adding a column with constraint Alexander Farber <alexander.farber@gmail.com>
Re: Adding a column with constraint "David Johnston" <polobo@yahoo.com>
Re: Adding a column with constraint Alexander Farber <alexander.farber@gmail.com>
Re: Adding a column with constraint Andrew Sullivan <ajs@crankycanuck.ca>
Hello,

I have a paranoic question.

In PostgreSQL 8.4.7 I had a table to store started, completed and
interrupted games :

# \d pref_match
                          Table "public.pref_match"
  Column   |         Type          |                Modifiers
-----------+-----------------------+-----------------------------------------
 id        | character varying(32) |
 started   | integer               | default 0
 completed | integer               | default 0
 quit      | integer               | default 0
 yw        | character(7)          | default to_char(now(), 'IYYY-IW'::text)
Check constraints:
    "pref_match_completed_check" CHECK (completed >= 0)
    "pref_match_quit_check" CHECK (quit >= 0)
    "pref_match_started_check" CHECK (started >= 0)
Foreign-key constraints:
    "pref_match_id_fkey" FOREIGN KEY (id) REFERENCES pref_users(id)

And have tried to add a column "win" with a check (to document the won games):

# alter table pref_match add column win integer default 0 check
(completed >= win and win >= 0);

Now I have:

# \d pref_match
                          Table "public.pref_match"
  Column   |         Type          |                Modifiers
-----------+-----------------------+-----------------------------------------
 id        | character varying(32) |
 started   | integer               | default 0
 completed | integer               | default 0
 quit      | integer               | default 0
 yw        | character(7)          | default to_char(now(), 'IYYY-IW'::text)
 win       | integer               | default 0
Check constraints:
    "pref_match_check" CHECK (completed >= win AND win >= 0)
    "pref_match_completed_check" CHECK (completed >= 0)
    "pref_match_quit_check" CHECK (quit >= 0)
    "pref_match_started_check" CHECK (started >= 0)
Foreign-key constraints:
    "pref_match_id_fkey" FOREIGN KEY (id) REFERENCES pref_users(id)

Shouldn't the line

    "pref_match_check" CHECK (completed >= win AND win >= 0)

above actually be:

    "pref_match_win_check" CHECK (completed >= win AND win >= 0)

? Does it indicate something went wrong or is it just cosmetic issue?

Thank you
Alex
В списке pgsql-general по дате отправления
От: Gauthier, Dave
Дата:
Сообщение: regexp problem
От: Steve Crawford
Дата:
Сообщение: Re: regexp problem
FAQ