-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathcomplex_table.sql
83 lines (66 loc) · 1.57 KB
/
complex_table.sql
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
CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
CREATE TYPE complex_type AS (
x INTEGER,
y INTEGER,
z BIGINT,
x1 NUMERIC(10, 2)
);
CREATE TABLE example_table (
-- Numeric types
id SERIAL PRIMARY KEY,
small_int_col SMALLINT,
integer_col INTEGER,
big_int_col BIGINT,
decimal_col DECIMAL(10, 2),
numeric_col NUMERIC(10, 2),
real_col REAL,
double_col DOUBLE PRECISION,
-- Character types
char_col CHAR(10),
varchar_col VARCHAR(255),
text_col TEXT,
-- Binary data types
bytea_col BYTEA,
-- Date/Time types
date_col DATE,
time_col TIME,
timestamp_col TIMESTAMP,
timestamptz_col TIMESTAMP WITH TIME ZONE,
interval_col INTERVAL,
-- Boolean type
boolean_col BOOLEAN,
-- Enumerated type
mood_col mood,
-- Geometric types
point_col POINT,
line_col LINE,
lseg_col LSEG,
box_col BOX,
path_col PATH,
polygon_col POLYGON,
circle_col CIRCLE,
-- Network address types
inet_col INET,
cidr_col CIDR,
macaddr_col MACADDR,
-- Bit string type
bit_col BIT(8),
bit_varying_col BIT VARYING(64),
-- Text search types
tsvector_col TSVECTOR,
tsquery_col TSQUERY,
-- UUID type
uuid_col UUID,
-- XML type
xml_col XML,
-- JSON types
json_col JSON,
jsonb_col JSONB,
-- Arrays
int_array_col INTEGER[],
text_array_col TEXT[],
-- Range types
int_range_col INT4RANGE,
-- Custom composite type
composite_col complex_type
);