Use views to control user access to data _ MySQL

Source: Internet
Author: User
Q: My MicrosoftAccess2000 application writes data from the backend SQLServer2000 database. To prevent Access users from seeing all the data in the SQLServer2000 table, I want to use a view that only allows users to browse authorized data rows. Can I create a view that limits user access to SQL Server data? A: Yes. If each user asks only: my Microsoft Access 2000 application writes data from the back-end SQL Server 2000 database. To prevent Access users from seeing all the data in SQL Server 2000, I want to use a view that only allows users to browse authorized data rows. Can I create a view that limits user access to SQL Server data?

A: Yes. If each user logs on to Access using a unique user ID, you can create a view that limits user Access to SQL Server data. The following example creates a view:

Create view v_data
SELECT
FROM dbo. mytable AS
Inner join dbo. authtable AS B
ON (a. Pkey = B. DataKey
AND B. userid = suser_sname ())

This view limits user access by userid. It requires you to save a table (authtable) with the username that matches the specific primary key in the data table (mytable ). If your situation is relatively simple-you do not need to manage row access permissions for multiple users, you can insert the userid column into the data table, as shown in the following code:

Create view v_data
SELECT
FROM dbo. mytable AS
WHERE a. userid = suser_sname ()

-Microsoft SQL Server Development team

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.