Представления

=> CREATE VIEW authors_v AS
SELECT a.author_id,
       a.first_name || ' ' ||
	   a.last_name ||
	   coalesce(' ' || nullif(a.middle_name, ''), '') AS display_name
FROM   authors a;
CREATE VIEW
=> CREATE VIEW catalog_v AS
SELECT b.book_id,
       b.title AS display_name
FROM   books b;
CREATE VIEW
=> CREATE VIEW operations_v AS
SELECT book_id,
       CASE WHEN qty_change > 0 THEN 'Поступление' ELSE 'Покупка' END op_type, 
       abs(qty_change) qty_change, 
       to_char(date_created, 'DD.MM.YYYY') date_created
FROM   operations
ORDER BY operation_id;
CREATE VIEW