Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

SQL - View

Back


View

-- create or replace a view
CREATE OR REPLACE VIEW view_name AS
select_query;

-- query a view
SELECT * FROM view_name;

-- remove a view
DROP VIEW IF EXISTS view_name;

-- rename a view


CREATE OR REPLACE VIEW customer_info AS
SELECT first_name
, last_name
, address
, district
FROM customer
INNER JOIN address
ON customer.address_id = address.address_id;

ALTER VIEW customer_info
RENAME TO c_info;

SELECT * FROM c_info;

DROP VIEW IF EXISTS c_info;

TOP