Possible Duplicate:
Use SQL View or SQL Query?
What is the reason writting a views instead of writting a sql statement?
Yes, there are lots of reasons.
invoices_2011 view with just invoices made in 2011 from the table invoices.Update:
On the example asked:
Let's say you have this table:
create table customers (
customer_id integer primary key,
name varchar(200) not null,
dob date
);
And you want user bart to see only name and dob of customers born before 1980. You can't grant access to customers table to bart because he could see anything stored on it.
You instead create a view:
create view customers_1980 as
select name, dob from customers
where dob < '1980-01-01';
And then grant bart access to that view:
grant select on customers_1980 to bart;
This way, bart will only have access to the restricted view subset of customers table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With