Best Online Tutorials

SQL Tutorial

Free SQL Tutorial

SQL Interview Questions

SQL Practice Questions

SQL Tips & Tricks

SQL Errors

SQL Books

Angular Tutorial

Free Angular Tutorial

Angular Interview Questions

Angular Practice Questions

Angular Tips & Tricks

Angular Errors

Angular Books

Node.js Tutorial

Free Node.js Tutorial

Node.js Interview Questions

Node.js Practice Questions

Node.js Tips & Tricks

Node.js Errors

Node.js Books

React.js Tutorial

Free React.js Tutorial

React.js Interview Questions

React.js Practice Questions

React.js Tips & Tricks

React.js Errors

React.js Books

SSIS Tutorial

Free SSIS Tutorial

SSIS Interview Questions

SSIS Practice Questions

SSIS Tips & Tricks

SSIS Errors

SSIS Books

SEO Tutorial

Free SEO Tutorial

SEO Interview Questions

SEO Practice Questions

SEO Tips & Tricks

SEO Errors

SEO Books

Javascript Tutorial

Free Javascript Tutorial

Javascript Interview Questions

Javascript Practice Questions

Javascript Tips & Tricks

Javascript Errors

Javascript Books

MongoDB Tutorial

Free MongoDB Tutorial

MongoDB Interview Questions

MongoDB Practice Questions

MongoDB Tips & Tricks

MongoDB Errors

MongoDB Books

Next.js Tutorial

Free Next.js Tutorial

Next.js Interview Questions

Next.js Practice Questions

Next.js Tips & Tricks

Next.js Errors

Next.js Books

SQL-Views 

Pooja Goel  |   Nov 5, 2019  |  Views: 16

Description:

View is a virtual table. It can have data from one or more tables.


It contains Rows and columns, just like Real Table.View can either have all rows of a table or specific rows based on condition.


Creating a View


Syntax :To create view


CREATE VIEW VIEW_NAME
AS
SELECT Column1,Column2,… FROM Table_Name
WHERE condition

Example :

Consider following Table “Employee”

 


You can create View named as “EMP_V1” whose EmpId are 1,2 by using below query.


Query:

CREATE VIEW EMP_V1 
AS
SELECT * FROM  Employee where id in(1,2)

 You can check created view by using below syntax.

SELECT * from EMP_V1

Output :

 


Updating a View


UPDATE Command for View , Just like Update command for table.


Syntax:

UPDATE View_Name Set Value Where Condition


Example :

You can update Value of Field name whose id=1 in above created View EMP_V1.


Query :

UPDATE EMP_V1 SET NAME='JIJIN' Where ID=1

Output:

 

 


Dropping a View

Dropping command is used to delete view.


Syntax:

DROP VIEW View_Name

Example :

The following syntax drops “EMP_V1” view

DROP VIEW EMP_V1

Listing Views

Once Views is created in a database , You can check list of all views in a database by using following statement.

Select * from sys.views

Output : 

 


Types of Views:


There are two types of views:

1) Simple View : It can have data from one table.

2) Complex View : It can have data from one or more table.


Comments:
Content Contributor
Pooja Goel

Pooja Goel

Sr. Software developer at Damco Solutions Pvt. Ltd.  |   Noida, Uttar Pradesh, India

I am a sr. software developer working on technologies like SQL, SSIS, SSRS, DB2,Tableau, ASP.NET having 7 years of experience.


Read related articles

SQL-CURSOR

Pooja Goel  |   Nov 16, 2019  |  Views: 10

SQL-Normalization

Pooja Goel  |   Nov 16, 2019  |  Views: 13

SQL-Injection

Pooja Goel  |   Nov 16, 2019  |  Views: 18

SQL-Convert/Cast Function

Pooja Goel  |   Nov 15, 2019  |  Views: 7

SQL-DENSE_RANK()

Pooja Goel  |   Nov 14, 2019  |  Views: 21

SQL-RANK()

Pooja Goel  |   Nov 14, 2019  |  Views: 9

SQL-Row_Number()

Pooja Goel  |   Nov 14, 2019  |  Views: 5

SQL-DATA TYPE

Pooja Goel  |   Nov 11, 2019  |  Views: 15

SQL-String Functions

Pooja Goel  |   Nov 11, 2019  |  Views: 19

SQL- Date Functions

Pooja Goel  |   Nov 11, 2019  |  Views: 12

SQL-TRIGGER

Pooja Goel  |   Nov 11, 2019  |  Views: 8

SQL-CTE

Pooja Goel  |   Nov 10, 2019  |  Views: 10

SQL-Stored Procedures

Pooja Goel  |   Nov 10, 2019  |  Views: 10

SQL-Temporary Tables

Pooja Goel  |   Nov 9, 2019  |  Views: 7

SQL-Merge

Pooja Goel  |   Nov 9, 2019  |  Views: 12

SQL-Subquery

Pooja Goel  |   Nov 9, 2019  |  Views: 50

SQL-EXISTS Operator

Pooja Goel  |   Nov 9, 2019  |  Views: 18

SQL- AND & OR Operator

Pooja Goel  |   Nov 8, 2019  |  Views: 7

SQl-Group by/Order by Clause

Pooja Goel  |   Nov 8, 2019  |  Views: 7

SQL-Where/Having Clauses

Pooja Goel  |   Nov 7, 2019  |  Views: 7

SQL-TOP Clause

Pooja Goel  |   Nov 7, 2019  |  Views: 14

SQL-CASE STATEMENT

Pooja Goel  |   Nov 7, 2019  |  Views: 10

SQL-UNION/UNION ALL

Pooja Goel  |   Nov 7, 2019  |  Views: 5

SQL-COMMENTS

Pooja Goel  |   Nov 6, 2019  |  Views: 39

SQL- ALIAS SYNTAX

Pooja Goel  |   Nov 6, 2019  |  Views: 5

SQL-IS NULL/ NOT NULL

Pooja Goel  |   Nov 6, 2019  |  Views: 9

SQL-IN & BETWEEN

Pooja Goel  |   Nov 6, 2019  |  Views: 8

SQL- DDL, DML, TCL and DCL

Pooja Goel  |   Nov 6, 2019  |  Views: 21

SQL-Aggregate Function

Pooja Goel  |   Nov 5, 2019  |  Views: 6

SQL-Like

Pooja Goel  |   Nov 5, 2019  |  Views: 13

SQL-Constraints

Pooja Goel  |   Nov 5, 2019  |  Views: 19

SQL-Views

Pooja Goel  |   Nov 5, 2019  |  Views: 17

SQL-Indexes

Pooja Goel  |   Nov 5, 2019  |  Views: 9

SQL-JOINS

Pooja Goel  |   Nov 4, 2019  |  Views: 29

SQL-SELECT Statement

Pooja Goel  |   Nov 4, 2019  |  Views: 20

SQL- DELETE Statement

Pooja Goel  |   Nov 4, 2019  |  Views: 20

SQL- UPDATE Statement

Pooja Goel  |   Nov 4, 2019  |  Views: 20

SQL- INSERT Statement

Pooja Goel  |   Nov 4, 2019  |  Views: 32

SQL- DROP / TRUNCATE TABLE

Pooja Goel  |   Nov 4, 2019  |  Views: 35

SQL-CREATE TABLE

Pooja Goel  |   Nov 4, 2019  |  Views: 30

SQL-DROP DATABASE

Pooja Goel  |   Nov 4, 2019  |  Views: 37

SQL-CREATE DATABASE

Pooja Goel  |   Nov 4, 2019  |  Views: 50

SQL-Introduction

Pooja Goel  |   Nov 4, 2019  |  Views: 293

Want to sell your software ?-

If you want to sell your readymade software to the genuine clients or businessman, list your software with details and demo links.

  • Sell ERP
  • Sell Website Clones
  • Sell App Clones
  • Sell Readymade Portals
  • Sell Readymade Websites
  • Sell Mobile Apps
  • Sell Window Apps

Clients will find it using our advanced search filter and will contact you directly.

No any charge for the product lsiting.

Do you own a Company ?+

Property.sale

Buy or Sell Commercial Property+

Are you a freelancer ?+

Looking for a job ?+

Are you a Service Provider ?+

Are you a blogger ?+

Do you own an IT Institute ?+



Property.sale