July 2010
Intermediate to advanced
840 pages
16h 33m
English
When you configure a system, you might want to have a way to set and keep constants in the schema. One method for doing this is to have a one-row table that can be set with default values at the start and then updated only by someone with administrative privileges.
CREATE TABLE Constants
(lock CHAR(1) DEFAULT 'X'
NOT NULL PRIMARY KEY
CHECK (lock = 'X'),
pi FLOAT DEFAULT 3.142592653 NOT NULL,
e FLOAT DEFAULT 2.71828182 NOT NULL,
phi FLOAT DEFAULT 1.6180339887 NOT NULL,
...);To initialize the row, execute this statement:
INSERT INTO Constants VALUES DEFAULTS;
The lock column ensures that there is only one row, and the default values load the initial values. These defaults can include the current user and current ...
Read now
Unlock full access