Friday, 22 April 2016

How to create, list and delete views ?


Create view
CREATE VIEW myView AS
  SELECT f.id, f.title, f.description, c.message
  FROM faq f, comment c
  WHERE f.id = c.faqID;

List views
Display all tables + views
SHOW TABLES;

Display all tables + views along with their types (table or view)
SHOW FULL TABLES;
tables | tables_type
--------------------
 t1    |  table
 t2    |  table
 v1    |  view


Delete view
DROP VIEW myView;

No comments:

Post a Comment

Note: only a member of this blog may post a comment.