Subject | RE: [firebird-support] SQL statements from all views |
---|---|
Author | Svein Erling Tysvær |
Post date | 2011-05-26T13:24:41Z |
>Hi,Try looking around in the system tables, the SQL below will hopefully (I just looked at the system tables, so there might be things I overlooked), if executed in a recent Firebird version, report the name of the view, a field name in the view and the source of the view (if not deleted) in a blob. Of course, you're unlikely to want the table name and the entire source code to be returned for each field of the view, but this should be a starting point.
>
> I would like to made some migration tool and I need to get SQL statement of all
> views from my FirebirdSQL database. Is this possible and how to get this scripts?
>
> Thanks in advanced...
I said recent Firebird version, since rdb$relation_type has been added since Firebird 1.5. There I'd e.g. check that rdb$view_source wasn't NULL.
select r.rdb$relation_name, r.rdb$view_source, rf.rdb$field_name
from rdb$relations r
join rdb$relation_fields rf on r.rdb$relation_name = rf.rdb$relation_name
where r.rdb$relation_type = 1
order by r.rdb$relation_name, rf.rdb$field_position
HTH,
Set