CREATE OR REPLACE FORCE VIEW "PLANTA_FK_COLUMNS" ("ID", "NAME", "TABLE_ID", "DB_POS", "SQL_FLAGS") AS 
select "ID","NAME","TABLE_ID","DB_POS","SQL_FLAGS" from planta_columns c
where exists (
	select 1 from planta_fks fk
	where c.table_id = fk.table_id
	and c.db_pos between fk.first_db_pos and fk.last_db_pos
) order by c.table_id asc, c.db_pos asc;/
