Re: How to build a TRIGGER in POSTGERSQL

Поиск
Список
Период
Сортировка
От darcy@druid.net (D'Arcy J.M. Cain)
Тема Re: How to build a TRIGGER in POSTGERSQL
Дата
Msg-id 20010619114308.716CC1A78@druid.net
обсуждение исходный текст
Ответ на How to build a TRIGGER in POSTGERSQL  (Ilan Fait <ilan@iweb.com>)
Список pgsql-sql
Thus spake Ilan Fait
>       1) I need to build a trigger that every time I insert into the table
> one of the columns will  get +1 number.

The easiest way in PostgreSQL is to simply make the field a serial type.
 CREATE TABLE mytable (   id SERIAL PRIMARY KEY,   myname TEXT);

>         2) what is  equal to 'sysdate' (to get/put the system date in a
> table)  in PostGerSQL.

Again, the table definition can handle this.
 CREATE TABLE mytable (   id SERIAL PRIMARY KEY,   mydate DATE DEFAULT CURRENT_DATE,   myname TEXT);

You should check out the docs on the web site.  They are quite comprehensive.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Sequence behaviour.
Следующее
От: David BOURIAUD
Дата:
Сообщение: About primary keys.