-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_create_table_temp_tables.sql
More file actions
93 lines (93 loc) · 2.35 KB
/
Copy path_create_table_temp_tables.sql
File metadata and controls
93 lines (93 loc) · 2.35 KB
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
create function schema._create_table_temp_tables(
_schemas text[],
_create_columns boolean = true,
_create_constraints boolean = true,
_create_indexes boolean = true,
_create_triggers boolean = true,
_create_policies boolean = true,
_create_sequences boolean = true
)
returns void
language plpgsql
as
$$
begin
if _create_columns then
create temp table _columns on commit drop as
select
t.type,
t.schema,
t.name,
t.table_schema,
t.table_name,
t.order_by,
t.comment,
t.short_definition,
t.definition
from schema._columns(_schemas) t;
end if;
if _create_constraints then
create temp table _constraints on commit drop as
select
t.type,
t.order_by,
t.schema,
t.name,
t.table_schema,
t.table_name,
t.comment,
t.short_definition,
t.definition
from schema._constraints(_schemas) t;
end if;
if _create_indexes then
create temp table _indexes on commit drop as
select
t.type,
t.schema,
t.name,
t.table_schema,
t.table_name,
t.comment,
t.definition
from schema._indexes(_schemas) t;
end if;
if _create_triggers then
create temp table _triggers on commit drop as
select
t.type,
t.schema,
t.name,
t.table_schema,
t.table_name,
t.comment,
t.definition
from schema._triggers(_schemas) t;
end if;
if _create_policies then
create temp table _policies on commit drop as
select
t.type,
t.schema,
t.name,
t.table_schema,
t.table_name,
t.comment,
t.definition
from schema._policies(_schemas) t;
end if;
if _create_sequences then
create temp table _sequences on commit drop as
select
t.type,
t.schema,
t.name,
t.table_schema,
t.table_name,
t.column_name,
t.comment,
t.definition
from schema._sequences(_schemas) t;
end if;
end;
$$;