**# EXAMPLE SQL VIEWS:**
CREATE VIEW running_contract_ok_balances AS
-- Creates a virtual table whose contents (columns and rows) are defined by a query.
-- Use this statement to create a view of the data in one or more tables in the database.
WITH cte_running_contract_ok_balances AS (SELECT
*,
amount-payments as Balance
FROM bank.loan
WHERE STATUS = 'C'
ORDER BY Balance
)
SELECT * FROM cte_running_contract_ok_balances;
CREATE OR REPLACE VIEW customer_status_D AS
-- if a view of the same name already exists, it is replaced.
SELECT * FROM bank.loan
WHERE STATUS = 'D'
WITH CHECK OPTION;
-- CHECK OPTION is an optional clause on the CREATE VIEW statement.
-- It specifies the level of checking when data is inserted or updated through a view.
-- CHECK OPTION is only adjudicate to the WHERE clause
**# EXAMPLE SQL DROP VIEWS:**
DROP VIEW IF EXISTS running_contract_ok_balances;
-- the definition of the view and other information about the view is deleted
-- from the system catalog.