dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL
Expertise: Intermediate
May 20, 2019

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Adjusting Views to Reduce Visibility of Data in MySQL

Let us consider a table representing employee data with a few columns, and, of course, their salary details as well.

It is not wise to expose this table to all querying entities since there is sensitive data that makes sharing the contents problematic.

In real time, there are VIEWS that can come in handy. You can create a VIEW with only the columns that need to be exposed and share that VIEW or permit read operation of that VIEW to users across various departments of the organization.

In MySQL, the syntax to create a VIEW is as below:

CREATE VIEW <VIEW_NAME> AS SELECT * FROM <TABLE_NAME>

The above syntax can be customized as needed. You must replace the * with the columns that you need to ensure that the sensitive data is not part of the view and thereby preventing it from being exposed. Of course, you need not permit anyone to access the <TABLE_NAME>, thereby ensuring privacy.

Example:

CREATE VIEW EMPLOYEE_DETAILS_VIEW AS SELECT EMP_ID, EMP_NAME, EMP_DEPT, EMP_DOB FROM EMPLOYEE_DETAILS

And yes, there are other conditional CREATE options that you can always explore.

Sridhar M S
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date