Skip to content

Instantly share code, notes, and snippets.

@martinusso
Last active November 10, 2018 10:58
Show Gist options
  • Save martinusso/9006260 to your computer and use it in GitHub Desktop.
Save martinusso/9006260 to your computer and use it in GitHub Desktop.
Playing with Firebird System Tables
-- [en] select primary key field of all tables
-- [pt] selecionar o campo primary key das tabelas
select
i.rdb$index_name,
s.rdb$field_name
from
rdb$indices i
left join rdb$index_segments s on i.rdb$index_name = s.rdb$index_name
left join rdb$relation_constraints rc on rc.rdb$index_name = i.rdb$index_name
where
rc.rdb$constraint_type = 'PRIMARY KEY'
-- [en] select all tables
-- [pt] selecionar todas as tabelas
select distinct
rdb$relation_name
from
rdb$relation_fields
where
rdb$system_flag = 0
and
rdb$view_context is null;
-- [en] select all tables and views
-- [pt] selecionar todas as tabelas e views
select distinct
rdb$relation_name
from
rdb$relation_fields
where
rdb$system_flag = 0;
-- [en] select all views
-- [pt] selecionar todas as views
select distinct
rdb$view_name
from
rdb$view_relations;
select
rdb$type,
rdb$type_name
from
rdb$types
where
rdb$field_name = 'rdb$object_type'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment