Create a view : Create View « View « SQL / MySQL






Create a view

    
mysql>
mysql>
mysql> CREATE TABLE titles (
    ->   titleID int(11),
    ->   title varchar(100),
    ->   subtitle varchar(100),
    ->   authors varchar(255)
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>
mysql>
mysql> INSERT INTO titles VALUES (1,'Linux','Installation, Konfiguration, Anwendung','Tom'),
    ->                                 (2,'The Definitive Guide to Excel VBA',NULL,'Tom, Kramer'),
    ->                                 (3,'Client Server Survival Guide',NULL,'Bob, Amy'),
    ->                                 (4,'Web Application Development with PHP 4.0',NULL,'Green'),
    ->                                 (7,'MySQL',null,'DuBois Paul'),
    ->                                 (9,'MySQL & mSQL',NULL,'King Tim, Reese Georg');
Query OK, 6 rows affected (0.00 sec)
Records: 6  Duplicates: 0  Warnings: 0

mysql>
mysql>
mysql>
mysql> CREATE or replace VIEW v1 AS
    -> SELECT titleID, title, subtitle FROM titles
    -> ORDER BY title, subtitle;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> drop table titles;
Query OK, 0 rows affected (0.00 sec)

mysql>

   
    
    
    
  








Related examples in the same category

1.Creating Views
2.Creating a View with Specified Column Names
3.Creating a View with Joined Tables
4.Adding ORDER BY to the Joined Table View
5.Using a GROUP BY Clause to Create a View
6.Using a GROUP BY Clause to Create a View ALGORITHM = TEMPTABLE
7.Using HAVING with GROUP BY to Create a View
8.Creating a View with UNION
9.Creating a view by joining two tables
10.Create view for a date range
11.Create view for user information
12.View with subquery
13.Create view with calculation
14.Create view and rename the backend column names
15.Create view for aggregate functions
16.Create a view in which the difference between the number of sets won and the number of sets lost are recorded