SQL Views || Virtual Tables || Steem Alliance Community.

in Steem Alliance2 years ago

Hello Everyone,


1_20240207_153718_0000.jpg

Good evening everyone, how are you, i hope you all guys will happy and good. By the grace of God, i am also good and wish the same for everyone. Today i am here with new post in which i will cover the Sql views and try to understand the virtual tables.

A SQL views are basically virtual table that are created by using a set of queries. It is not physical table in the database but it act like a table. views are perform the operation of encapsulations.

It is store the complex query with a single name and this name will store the result of this query and we can use it look like a table. we can limit the columns of table during the view creation. it enhanced the security and can restrict the accessing of sensitive data from general users. Views provide the better query performance. we will cover this topic with an example. it will help to understand it betterly.

Syntax

CREATE VIEW V_NAME AS
SELECT column1, column2
FROM table
WHERE condition;



For example, a table has total 5 column and we want to just show the data of 2 column and want hidden remaing column. then we will use the views.

CREATE VIEW v_user AS
SELECT id , name 
FROM users u
WHERE u.SECTOR = '1000'
AND u.salery          = '50000' ;



Another example. if we are getting data by using more then one table on th base of foreign and primery key and we want to encapsulate this query with just one name like table name. then we will make a view and encapsulate the query in it like.

CREATE VIEW v_user AS
SELECT a.id , u.name , u.address , a.acct_id
FROM users u left join account a
on u.id = a.id;


images (11).jpeg
Img src

View Selection,

After creating the view, we can use the view like table. Syntax is below shared as reference.

select * from v_user;

View Selection,

After creating the view, we can use the view like table. Syntax is below shared as reference.

select * from v_user;

Where clause

you can see the where clauses in the above provide queries, basically it is used for conditioning. in the above example, you can see the after wrtiting the where clause i use sector = '1000' . it mean i have add an condition, it will just store the result of those data in a view who have sector = 1000 remaining data of user will not store. it store the data temporaray not permanently becasue it get the data from queries show us.

It would be my pleasure if you will share your opinion and reviews on this topic

20230310_190323_0000.png

Please cast witness vote to @bangla.Witness or set proxy to @rme.

_
Vote @bangla.witness as witness
Set Proxy @rme as proxy

Special Thanks.

Cc: @rme
Cc: @hungry-griffin
Cc: @pennsif

Thanks for giving your precious time to my post.
Follow | Upvote | Share | Comments
Follow me on Instagram.
Instagram

🆃🅷🅰️🅽🅺 🆈🅾️🆄

Sort:  

Thank you, friend!
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
image.png
please click it!
image.png
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)

The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.103
BTC 64123.21
ETH 1866.53
USDT 1.00
SBD 0.35