11 сент. 2009 г.

A little Firebird SQL trick

How to ensure that a table contains no more than one record? Triggers should not be envolved. Here is a code:

CREATE TABLE test (
   id     INTEGER NOT NULL PRIMARY KEY,
   lock   INTEGER DEFAULT 1 UNIQUE,

   CHECK (lock = 1)
)

Комментариев нет:

Отправить комментарий