CREATE OR REPLACE FORCE VIEW "PLANTA_PK_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_pks pk
	where c.table_id = pk.table_id
	and c.db_pos between pk.first_db_pos and pk.last_db_pos
) order by c.table_id asc, c.db_pos asc;/
