File: create_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 (164 lines) | stat: -rw-r--r-- 3,053 bytes parent folder | download
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
CREATE TABLE t1 (
    col1 INTEGER PRIMARY KEY,
    col2 VARCHAR(5) NOT NULL
)
DISTKEY(col1)
SORTKEY(col1)
;

CREATE TABLE t1 (
    col1 INTEGER PRIMARY KEY,
    col2 VARCHAR(5) GENERATED BY DEFAULT AS IDENTITY (1, 1)
)
DISTKEY(col1)
SORTKEY(col1)
;

CREATE TABLE t1 (
    col1 INTEGER PRIMARY KEY,
    col2 VARCHAR(5),
    col3 VARCHAR(5),
    col4 VARCHAR(5),
    col5 VARCHAR(5),
    col6 VARCHAR(5)
)
DISTKEY (col1)
COMPOUND SORTKEY (col4, col5, col6)
;

CREATE TABLE t1 (
    col1 INTEGER PRIMARY KEY,
    col2 VARCHAR(5) REFERENCES t2 (col1)
)
DISTKEY(col1)
SORTKEY(col1)
;

CREATE TABLE IF NOT EXISTS t1 (
    col1 INTEGER PRIMARY KEY,
    col2 VARCHAR(5)
)
DISTKEY(col1)
SORTKEY(col1)
;

CREATE TEMPORARY TABLE t1 (
    col1 INTEGER PRIMARY KEY,
    col2 VARCHAR(5)
)
DISTKEY(col1)
SORTKEY(col1)
;

CREATE TEMP TABLE t1 (
    col1 INTEGER PRIMARY KEY,
    col2 VARCHAR(5)
)
DISTKEY(col1)
SORTKEY(col1)
;

CREATE LOCAL TEMPORARY TABLE t1 (
    col1 INTEGER UNIQUE,
    col2 VARCHAR(5)
)
BACKUP YES
;

CREATE TEMPORARY TABLE t1 (
    col1 INTEGER PRIMARY KEY,
    col2 VARCHAR(5)
)
BACKUP NO
DISTKEY(col1)
SORTKEY(col1, col2)
;

CREATE TABLE t1 (
    col1 INTEGER ENCODE AZ64 PRIMARY KEY,
    col2 VARCHAR(5) ENCODE TEXT255
)
DISTKEY(col1)
SORTKEY AUTO
DISTSTYLE EVEN
;

CREATE TABLE schema1.t1 (
    col1 INTEGER ENCODE AZ64 PRIMARY KEY,
    col2 VARCHAR(5) ENCODE TEXT255,
    col3 VARCHAR(5) COLLATE CASE_SENSITIVE,
    col3 VARCHAR(5) COLLATE CASE_INSENSITIVE
)
;

CREATE TABLE UniqueKey_demo (
 col1 INT NOT NULL UNIQUE
 ,col2 DATE
 ,col3 VARCHAR(60 )
, UNIQUE (col1)
) DISTKEY(col1)
COMPOUND SORTKEY(col1, col2);

CREATE TABLE UniqueKey_demo (
 col1 INT NOT NULL UNIQUE
 ,col2 DATE
 ,col3 VARCHAR(60 )
, PRIMARY KEY (col1)
) DISTKEY(col1)
INTERLEAVED SORTKEY (col1, col2);

CREATE TEMP TABLE IF NOT EXISTS UniqueKey_demo (
 col1 INT NOT NULL UNIQUE
 ,col2 DATE
 ,col3 VARCHAR(60 )
, FOREIGN KEY (col3) REFERENCES t2 (col5)
) ;

CREATE TEMP TABLE t1 (LIKE schema1.t2);

CREATE TEMP TABLE t1 (LIKE schema1.t2 INCLUDING DEFAULTS);

CREATE TABLE t1 (LIKE schema1.t2 EXCLUDING DEFAULTS);

CREATE TABLE some_schema.example_table (
    LIKE some_schema.another_table INCLUDING DEFAULTS
    , LIKE some_schema.next_table EXCLUDING DEFAULTS
    );

CREATE TABLE some_schema.example_table (
    LIKE some_schema.another_table INCLUDING DEFAULTS
    , col_name VARCHAR(5)
    );

CREATE TABLE some_table
(
    some_column INTEGER NOT NULL DEFAULT 1
);

CREATE TABLE IdentityColumn_demo (
    col1 BIGINT IDENTITY
);

CREATE TABLE IdentityColumnGeneratedByDefault_demo (
    col1 BIGINT GENERATED BY DEFAULT AS IDENTITY
);

CREATE TABLE IdentityColumnNotNull_demo (
    col1 BIGINT IDENTITY NOT NULL
);

CREATE TABLE IdentityColumnGeneratedByDefaultNotNull_demo (
    col1 BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL
);

create table public.t1 ( c1 int, c2 int, c3 int, unique (c1, c2) );

create table public.t2
(
    c1 int,
    c2 int,
    c3 int,
    foreign key (c1, c2) references public.t1 (c1, c2)
);

create table test(col1 varchar(max));