w3reference home
SQL Tutorial


Bookmark and Share

SQL Views

You need to contact your DBA to check if you have access to create views for yourself. A view is a virtual table that has fields and data from some SQL table.

Create a view

Syntax:
CREATE VIEW view_name AS
SELECT column_name1, column_name2,....
FROM table_name
WHERE condition;
Consider the table, marks_maria, given below:
Subject I term II term III term IV term
Maths 90 78 75 80
English 72 68 76 62
French 78 75 63 58
Science 93 88 84 75
Suppose, we need to create a view which has Ist and IInd terms marks of French and Science. The SQL statement is given below:
CREATE VIEW marks AS
SELECT Subject, I term, II term
FROM marks_maria
WHERE Subject='French' OR Subject='Science';
The view named, marks will be created.

Query a view

A view can be queried just like a simple database. Suppose, we want to view the view above. We can view this view by the following SQL:
SELECT * FROM marks;
The view will be as follows:
Subject I term II term
French 78 75
Science 93 88

Delete a view

To delete a view, the syntax is:
DROP VIEW view_name;
The marks view can be deleted by the following SQL query:
DROP VIEW marks;
Code Validator
Learn FTP
Color finder
Link Checker
Free web designs
Coming soon!
Interview Questions...
'w3reference : Learn by examples ... Advanced to beginner's tutorials ...'
Ajax: AJAX tutorial1 | Apache: Apache HTTP Server | Restarting Apache | CSS: CSS Border | CSS Syntax | CSS Selector | CSS Comment | CVS: CVS Release | CVS Login | CVS Logout | CVS Annotate | Databases: Rolap Tutorial | OLAP Tutorial | OLTP Tutorial | data warehousing | Expect: HTML: html | Linux: Dot (.) conf files | Linux Mount Point | Linux Filesystem | SSH Tutorial | Linux Commands: cal | cat | cfdisk | chroot | MySQL: MySQL Commands | PHP: PHP Basics | PHP Variables | PHP Output (echo/print) | PHP String Concat | PL/SQL: PL/SQL Data Types | PL/SQL Control Structures | PL/SQL File Extensions | PL/SQL DBMS_OUTPUT package | Python: My first Python program | Shell: Starting Bash | Bash Redirection | Bash Pipes | Bash Variables | SQL: SQL Transactions | SQL Constraints | SQL Drop | SQL Union & Union All | SVN: svn architecture | SVN Repository | SVN Import | SVN Checkout | Tech: soap | Web Designing: Web Hosting | HTML/XHTML/CSS code validator | Learn FTP | Search Engine Optimization Tips | www: XML: XML vs HTML | XML Syntax | XML Tags, Elements and Attributes | XML Namespaces |
Sitemap | Disclaim | Privacy Policy | Contact | ©2007-2009 w3reference.com All Rights Reserved.