File: init_schema.sql

package info (click to toggle)
slony1-2 2.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,836 kB
  • ctags: 5,283
  • sloc: ansic: 21,239; sh: 13,008; sql: 11,299; xml: 9,172; perl: 2,803; yacc: 2,698; lex: 1,356; makefile: 747; awk: 24; lisp: 8
file content (42 lines) | stat: -rw-r--r-- 989 bytes parent folder | download | duplicates (7)
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
31
32
33
34
35
36
37
38
39
40
41
42
create schema foo;
set search_path to foo;
drop schema public;
CREATE TABLE foo.table1(
  id		SERIAL		PRIMARY KEY, 
  data		TEXT
);

CREATE TABLE foo.table2(
  id		SERIAL		UNIQUE NOT NULL, 
  table1_id	INT4		REFERENCES table1(id) 
					ON UPDATE CASCADE ON DELETE CASCADE, 
  data		TEXT
);

CREATE TABLE foo.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)
); 

-- Create some Evil names...
create schema "Schema.name";
create schema "Studly Spacey Schema";
create table "Schema.name"."user" (
  id integer,
  "user" text not null unique,
  primary key (id)
);

create table "Schema.name"."Capital Idea" (
  "user" text,
  description text,
  primary key("user")
);

create sequence "Studly Spacey Schema"."user";
create sequence "Schema.name"."a.periodic.sequence";