-
Notifications
You must be signed in to change notification settings - Fork 58
/
index.txt
113 lines (102 loc) · 2.97 KB
/
index.txt
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
================================================================================
Create simple index
================================================================================
CREATE INDEX ON tab(col);
--------------------------------------------------------------------------------
(program
(statement
(create_index
(keyword_create)
(keyword_index)
(keyword_on)
(object_reference
(identifier))
(index_fields
(field
(identifier))))))
================================================================================
Create named index with options
================================================================================
CREATE UNIQUE INDEX CONCURRENTLY
IF NOT EXISTS idx1
ON tab USING HASH(col ASC)
WHERE tab.col > 10;
--------------------------------------------------------------------------------
(program
(statement
(create_index
(keyword_create)
(keyword_unique)
(keyword_index)
(keyword_concurrently)
(keyword_if)
(keyword_not)
(keyword_exists)
(identifier)
(keyword_on)
(object_reference
(identifier))
(keyword_using)
(keyword_hash)
(index_fields
(field
(identifier)
(direction
(keyword_asc))))
(where
(keyword_where)
(binary_expression
(field
(object_reference
(identifier))
(identifier))
(literal))))))
================================================================================
Create unique index with complex index fields
================================================================================
CREATE UNIQUE INDEX foo_index ON foo (
md5(COALESCE(cat, '')) COLLATE some_collation ASC NULLS LAST,
dog some_operator_class(1),
(cow / 2)
);
--------------------------------------------------------------------------------
(program
(statement
(create_index
(keyword_create)
(keyword_unique)
(keyword_index)
column: (identifier)
(keyword_on)
(object_reference
name: (identifier))
(index_fields
(field
function: (invocation
(object_reference
name: (identifier))
parameter: (term
value: (invocation
(object_reference
name: (identifier))
parameter: (term
value: (field
name: (identifier)))
parameter: (term
value: (literal)))))
(keyword_collate)
(identifier)
(direction
(keyword_asc))
(keyword_nulls)
(keyword_last))
(field
column: (identifier)
opclass: (identifier)
opclass_parameters: (term
value: (literal)))
(field
expression: (binary_expression
left: (field
name: (identifier))
right: (literal)))))))