Home Sql Mysql-alter Views in SQL

Related Tutorials


 
 

Share on Google+Share on Google+

Views in SQL

Advertisement
A View is a virtual or imaginary table based on the outcome of a SELECT statement.

Views in SQL

     

A View is a virtual or imaginary table based on the outcome of a SELECT statement. A view include rows and columns as real table. A view include a fields is similar to one or more real tables in database. A view of a table does not store a data.

Understand with Example

The Tutorial illustrate an example from 'View in SQL'. To understand this example we create a table 'customer'. The create table is used to create a table customer with required field attribute and data type respectively.

 

 

 

 

Create Table 'customer':

create table customer(First_Name varchar(15),Last_Name varchar(15),Address varchar(15),City varchar(15),Country varchar(15));

Insert values into Table 'customer':

The insert into add the records or rows to the table 'customer'.

To see the detail of table 'customer':

The Select keywords returns you the set of records from table 'customer'.

select * from  customer;

 

Create View 'viewCustomer':

Now we apply view on Table 'customer'. The create VIEW is used to create a view 'viewCustomer' that contain the first_name,last_name and country field name  from table 'customer',

create VIEW viewCustomer as SELECT First_Name,Last_Name,Country
FROM Customer;

View Details :

The select  return the set of records or rows from 'viewCustomer'.

select * from viewCustomer;

Output is displayed as :

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 13, 2009

Related Tutorials

Discuss: Views in SQL   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com