-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexb_drop_objects.sql
More file actions
54 lines (53 loc) · 1.92 KB
/
exb_drop_objects.sql
File metadata and controls
54 lines (53 loc) · 1.92 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
-- template to create drop statements for all objects except specified in `not in (null)` fragments
execute block
returns (
name varchar(31)
, type_name varchar(31)
, drop_stmt varchar(128)
)
as
begin
-- author: atronah (look for me by this nickname on GitHub and GitLab)
-- source: https://github.com/atronah/firebird_utils
for select
'trigger' as type_name, rdb$trigger_name as name
from rdb$triggers
where rdb$system_flag = 0 and trim(rdb$trigger_name) not in (null)
union all
select 'procedure' as type_name, rdb$procedure_name as name
from rdb$procedures
where rdb$system_flag = 0 and trim(rdb$procedure_name) not in (null)
union all
select
'view' as type_name, rdb$relation_name as name
from rdb$relations
where rdb$system_flag = 0 and rdb$relation_type = 1 -- 1 - view
and trim(rdb$relation_name) not in (null)
union all
select
'table' as type_name, rdb$relation_name as name
from rdb$relations
where rdb$system_flag = 0 and coalesce(rdb$relation_type, 0) = 0 -- 0 - system or user-defined table
and trim(rdb$relation_name) not in (null)
union all
select
'domain' as type_name, rdb$field_name as name
from rdb$fields
where rdb$system_flag = 0 and trim(rdb$field_name) not in (null)
union all
select
'sequence' as type_name, rdb$generator_name as name
from rdb$generators
where rdb$system_flag = 0 and trim(rdb$generator_name) not in (null)
union all
select
'index' as type_name, rdb$index_name as name
from rdb$indices
where rdb$system_flag = 0 and trim(rdb$index_name) not in (null)
into type_name, name
do
begin
drop_stmt = 'drop ' || trim(type_name) || ' ' || trim(name) || ';';
suspend;
end
end