File: constraint.sch

package info (click to toggle)
pgmodeler 1.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,160 kB
  • sloc: cpp: 99,216; xml: 27; sh: 15; makefile: 6
file content (93 lines) | stat: -rw-r--r-- 1,678 bytes parent folder | download | duplicates (2)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# SQL definition for constraints
# CAUTION: Do not modify this file unless you know what you are doing.
# Code generation can be broken if incorrect changes are made.
%if {decl-in-table} %then
	$tb
%else
	@include "ddlend"

	[-- object: ] {name} [ | type: ] {sql-object} [ --] $br

	%if {table} %then
		[-- ] {drop}
		[ALTER TABLE ] {table} [ ADD ]
	%end
%end

[CONSTRAINT ] {name}

%if {ck-constr} %then
	[ CHECK ] ({expression})

	%if {no-inherit} %then [ NO INHERIT] %end

%end

%if {pk-constr} %then [ PRIMARY KEY ] ({src-columns}) %end

%if {uq-constr} %then
	[ UNIQUE ] 

	%if ({pgsql-ver} >=f "15.0") %and {nulls-not-distinct} %then
		[NULLS NOT DISTINCT ]
	%end

	({src-columns}) 
%end

%if {ex-constr} %then
	[ EXCLUDE ] $br
	$tb

	%if {index-type} %then
		[USING ] {index-type}
	%end

	( {elements} $br $tb )
%end

%if {pk-constr} %or {uq-constr} %then
	%if {factor} %then
		%if {decl-in-table} %then $br $tb %end
		[ WITH (FILLFACTOR = ] {factor} [)]
	%end
%end

%if {tablespace} %then
	$br
	%if {decl-in-table} %then $tb %end
	%if {pk-constr} %or {uq-constr} %or {ex-constr} %then [USING INDEX TABLESPACE ] {tablespace} %end
%end

%if {ex-constr} %and {expression} %then
	$sp WHERE $sp ( {expression})
%end

%if {fk-constr} %then
	[ FOREIGN KEY ] ({src-columns}) $br

	%if {decl-in-table} %then $tb %end
	[REFERENCES ] {ref-table} $sp ({dst-columns})
	$sp {comparison-type} $br

	%if {decl-in-table} %then $tb %end
	[ON DELETE ] {del-action} [ ON UPDATE ] {upd-action}
%end

%if {deferrable} %then
	[ DEFERRABLE ] {defer-type}
%end

%if {decl-in-table} %then 
	[,]
%else
	[;] 

	{ddl-end}
%end

%if %not {decl-in-table} %and {comment} %then
	{comment} $br
%end

$br