��在SQL中定义视图的SQL语句如下:
��create view v as <查询表达式>
例如:
create view all-customer as
��(select branch-name, customer-name
��from depositor d, account a
��where d.account-number = a.account-number)
union
��(select branch-name, customer-name
��from borrower b, loan l
��where b.loan-number = l.loan-number)
在定义视图时可以显式地指定视图中的属性名,例如:
create view branch-total-loan (branch-name, total-loan) as
��select branch-name, sum(amount)
��from loan
��group by branch-name