1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
CREATE TABLE table1(
id SERIAL PRIMARY KEY,
data TEXT
);
CREATE TABLE table2(
id SERIAL UNIQUE NOT NULL,
table1_id INT4 REFERENCES table1(id)
ON UPDATE CASCADE ON DELETE CASCADE,
data TEXT
);
CREATE TABLE table3(
id SERIAL,
table2_id INT4 REFERENCES table2(id)
ON UPDATE SET NULL ON DELETE SET NULL,
mod_date TIMESTAMPTZ NOT NULL DEFAULT now(),
data FLOAT NOT NULL DEFAULT random()
CONSTRAINT table3_date_check CHECK (mod_date <= now()),
primary key (id)
);
-- Table to perform UTF8 tests (checks multibyte; should be helpful in
-- preventing problems with Asian character sets too)
CREATE TABLE utf8table (
id serial,
string text,
primary key(id)
);
INSERT INTO utf8table (string) VALUES ('1b\303\241r') ;
|