5.9.08

Views in sql server


Views in sql server:
View is a very good concept in sql server. View is nothing but a reference for a table. It inturn refer the table itself.
Its like a layer placed on the table. So that, we will be providing an extra layer over the tables. Instead of a using complex join, we
can views which will hold the entire logic and hope it's supporting encapsulation logic :-).
Creating a sample table:

CREATE TABLE venkat1(id int, name varchar(100))

INSERT INTO venkat VALUES(1,'aa;bb;cc;dd;')

INSERT INTO venkat VALUES(2,'EE;FF;GG;HH')

SELECT * FROM venkat

Creating view on the table:


CREATE VIEW VENKATVIEW AS

SELECT * FROM venkat

Selecting data from the view:


SELECT * FROM VENKATVIEW
DML operations on the view:
(Insert statement on views)


INSERT INTO VENKATVIEW VALUES(2,'VE')

SELECT * FROM VENKAT

(Delete statement on views)


DELETE FROM VENKATVIEW WHERE ID=1
(Update statement on views)


UPDATE VENKATVIEW SET NAME='AA' WHERE ID=2

Happy Learning!!!

Regards,

Venkatesan Prabu .J

1 comment:

  1. Free classified ads... promote your sites/blog

    No login required...

    http://publishonweb.blogspot.com/

    ReplyDelete