Results 1 to 4 of 4

Thread: what are VIEWS in SQL ?

  1. #1
    Join Date
    Nov 2009
    Posts
    51

    what are VIEWS in SQL ?

    Hi,
    I am just started learning SQL from last 5 days.I know how to fetch record using query.I just begin to learn chapter on VIEW.I just want to know that why we don't use SELECT command to extract records directly from the table rather than creating a VIEW ?
    Please help me.

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: what are VIEWS in SQL ?

    A view is a type of virtual table that consists of columns from one or more tables. It is stored in the database. We can fetch data from this view using simple query.It is used to combine data from two or more table.Once you create a view, you can reference it like any other table in a database.A view is use as a security mechanism. It ensures that users are able to retrieve and modify only the specific data seen by them. Users cannot access the remaining data in the underlying tables.

    Syntax of view:

    CREATE VIEW view_name
    [(column_name[,column_name]….)]
    [WITH ENCRYPTION]
    AS select_statement [WITH CHECK OPTION]

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: what are VIEWS in SQL ?

    In SQL, a view is like a virtual table based on result of SQL statement.A view is like normal table that contains rows and columns.The columns in a view are columns from one or more real tables in the database.VIEW is mainly used to secure some data from particular tables.

    Syntax for creating VIEW:

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


    You can update a view by using the following syntax:

    SQL CREATE OR REPLACE VIEW Syntax
    CREATE OR REPLACE VIEW view_name AS
    SELECT column_name(s)
    FROM table_name
    WHERE condition

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: what are VIEWS in SQL ?

    A view is type of a virtual table. It does not physically exist in database. VIEW is created by using query by joining one or more tables. VIEW is created to retrieve data from one or more tables.


    The syntax for creating a VIEW is as follows :

    CREATE VIEW view_name AS
    SELECT columns
    FROM table
    WHERE predicates;

    view_name specifies the name of the view
    column_name specifies the name of the column to be used in view.
    table is name of table from which we have to retrieve data.

    For example:

    CREATE VIEW [Products Above Average Price] AS
    SELECT ProductName,UnitPrice
    FROM Products
    WHERE UnitPrice>(SELECT AVG(UnitPrice) FROM Products)

Similar Threads

  1. What are your views on IPad 2?
    By Paheli in forum Portable Devices
    Replies: 4
    Last Post: 03-06-2011, 08:04 AM
  2. Views on end level of Fable 3
    By SawalGuru in forum Video Games
    Replies: 5
    Last Post: 16-05-2011, 10:37 PM
  3. Views regarding the LG Optimus 2x
    By Hafizz in forum Portable Devices
    Replies: 4
    Last Post: 12-02-2011, 10:26 AM
  4. What is the similarity between views and DBMS
    By Gonercase in forum Software Development
    Replies: 3
    Last Post: 10-01-2011, 03:55 AM
  5. How to set navigation views in FrontPage XP
    By Galbraith in forum Software Development
    Replies: 5
    Last Post: 23-02-2010, 06:12 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,020,091.74080 seconds with 16 queries