File: create_foreign_table.sql

package info (click to toggle)
sqlfluff 3.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,000 kB
  • sloc: python: 106,131; sql: 34,188; makefile: 52; sh: 8
file content (135 lines) | stat: -rw-r--r-- 5,280 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
CREATE FOREIGN TABLE foreign_table (
    simple_column integer,
    column_with_options char(5) OPTIONS (a 'foo', b 'bar'),
    column_with_collate text COLLATE "de_DE",
    column_with_not_null_constraint date NOT NULL,
    column_with_null_constraint varchar(50) NULL,
    column_with_check_constraint float CHECK (column_with_check_constraint > 0.0),
    column_with_default_constraint timestamp DEFAULT CURRENT_TIMESTAMP,
    column_with_generated_constraint bigint GENERATED ALWAYS AS (simple_column * 2) STORED,
    column_with_more_than_one_constraint int NOT NULL CHECK (column_with_more_than_one_constraint > 0),
    column_with_options_and_collate char(5) OPTIONS (a 'foo', b 'bar') COLLATE "es_ES",
    column_with_options_and_constraint char(5) OPTIONS (a 'foo', b 'bar') NOT NULL,
    column_with_collate_and_constraint char(5) COLLATE "de_DE" NOT NULL,
    column_with_options_collate_and_constraint char(5) OPTIONS (a 'foo', b 'bar') COLLATE "de_DE" NOT NULL,
    CHECK (simple_column > 0),
    CHECK (simple_column < 10) NO INHERIT,
    CONSTRAINT named_table_constraint CHECK (column_with_options <> ''),
    CONSTRAINT named_table_constraint_no_inherit CHECK (column_with_collate <> '') NO INHERIT
)
SERVER a_server;

CREATE FOREIGN TABLE IF NOT EXISTS foreign_table_that_might_already_exist (
    simple_column integer
)
SERVER a_server;

CREATE FOREIGN TABLE foreign_table_that_inherits (
    simple_column integer
)
INHERITS ( another_table )
SERVER a_server;

CREATE FOREIGN TABLE IF NOT EXISTS foreign_table_that_inherits_that_might_already_exist (
    simple_column integer
)
INHERITS ( another_table )
SERVER a_server;

CREATE FOREIGN TABLE foreign_table_with_options (
    simple_column integer
)
SERVER a_server
OPTIONS (c 'baz');

CREATE FOREIGN TABLE IF NOT EXISTS foreign_table_with_options_that_might_already_exist (
    simple_column integer
)
SERVER a_server
OPTIONS (c 'baz');

CREATE FOREIGN TABLE foreign_table_that_inherits_and_has_options (
    simple_column integer
)
INHERITS ( another_table )
SERVER a_server
OPTIONS (c 'baz');

CREATE FOREIGN TABLE IF NOT EXISTS foreign_table_that_inherits_and_has_options_that_might_already_exist (
    simple_column integer
)
INHERITS ( another_table )
SERVER a_server
OPTIONS (c 'baz');

CREATE FOREIGN TABLE foreign_table_partition_in
    PARTITION OF another_table FOR VALUES IN ('2016-07-01', '2016-08-01')
    SERVER a_server;

CREATE FOREIGN TABLE foreign_table_partition_from_min_to_max
    PARTITION OF another_table FOR VALUES FROM ('2016-07-01') TO ('2016-08-01')
    SERVER a_server;

CREATE FOREIGN TABLE foreign_table_partition_with
    PARTITION OF another_table FOR VALUES WITH ( MODULUS 2, REMAINDER 0)
    SERVER a_server;

CREATE FOREIGN TABLE IF NOT EXISTS foreign_table_partition_in_that_might_already_exist
    PARTITION OF another_table FOR VALUES IN ('2016-07-01', '2016-08-01')
    SERVER a_server;

CREATE FOREIGN TABLE IF NOT EXISTS foreign_table_partition_from_min_to_max_that_might_already_exist
    PARTITION OF another_table FOR VALUES FROM ('2016-07-01') TO ('2016-08-01')
    SERVER a_server;

CREATE FOREIGN TABLE IF NOT EXISTS foreign_table_partition_with_that_might_already_exist
    PARTITION OF another_table FOR VALUES WITH ( MODULUS 2, REMAINDER 0)
    SERVER a_server;

CREATE FOREIGN TABLE foreign_table_partition_in_with_options
    PARTITION OF another_table FOR VALUES IN ('2016-07-01', '2016-08-01')
    SERVER a_server
    OPTIONS (foo 'bar');

CREATE FOREIGN TABLE foreign_table_partition_from_min_to_max_with_options
    PARTITION OF another_table FOR VALUES FROM ('2016-07-01') TO ('2016-08-01')
    SERVER a_server
    OPTIONS (foo 'bar');

CREATE FOREIGN TABLE foreign_table_partition_with_with_options
    PARTITION OF another_table FOR VALUES WITH ( MODULUS 2, REMAINDER 0)
    SERVER a_server
    OPTIONS (foo 'bar');

CREATE FOREIGN TABLE foreign_table_partition_in_with_columns
    PARTITION OF another_table (
        simple_column,
        column_with_options WITH OPTIONS,
        column_with_not_null_constraint NOT NULL,
        column_with_null_constraint NULL,
        column_with_check_constraint CHECK (column_with_check_constraint > 0.0),
        column_with_default_constraint DEFAULT CURRENT_TIMESTAMP,
        column_with_generated_constraint GENERATED ALWAYS AS (simple_column * 2) STORED,
        column_with_more_than_one_constraint NOT NULL CHECK (column_with_more_than_one_constraint > 0),
        column_with_options_and_not_null_constraint WITH OPTIONS NOT NULL,
        CHECK (simple_column > 0),
        CHECK (simple_column < 10) NO INHERIT,
        CONSTRAINT named_table_constraint CHECK (column_with_options <> ''),
        CONSTRAINT named_table_constraint_no_inherit CHECK (column_with_options_and_not_null_constraint <> '')  NO INHERIT
    )
    FOR VALUES IN ('2016-07-01', '2016-08-01')
    SERVER a_server;

CREATE FOREIGN TABLE foreign_table_partition_with_from_min_to_max_with_columns
    PARTITION OF another_table (
        simple_column
    )
    FOR VALUES FROM ('2016-07-01') TO ('2016-08-01')
    SERVER a_server;

CREATE FOREIGN TABLE foreign_table_partition_with_with_columns
    PARTITION OF another_table (
        simple_column
    )
    FOR VALUES WITH ( MODULUS 2, REMAINDER 0)
    SERVER a_server;