By 25/02/2016 5 Comments

What Is VIEW & How To Create it using SQL?

  • SQL VIEW is a virtual database table which is created through result-sets of SQL statements.
  • An SQL VIEW is like a normal SQL database table contain rows and columns/fields etc.
  • An SQL VIEW has rows and columns which are originally come from on or more real tables in a database. When you update real tables in database the VIEW will also be updated automatically.
  • An SQL VIEW is made up of other real tables in a database.
  • SQL WHERE, joins and other functions can be used to create a VIEW.
  • In real world scenarios VIEWS can be created from multiple tables using joins
  • SQL VIEWS hide complexity which is found in SQL queries.
  • SQL VIEWS increase security mechanism.

Syntax:

CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition;

Example: Create a VIEW (view_country) from entire table (country)

CREATE VIEW view_country AS
SELECT *
FROM country;

Example: Create a VIEW (view_country) from selected fields of table (country)

CREATE VIEW view_country AS
SELECT country_name,location
FROM country;

Example: Create a VIEW (view_country) from a particular record from table (country)

CREATE VIEW view_country AS
SELECT *
FROM country
WHERE country_id = 1;

Example: Select/retrieve entire VIEW (view_country)

SELECT *
FROM view_country;






Posted in: Sql

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .