Bird
0
0

Which SQL statement correctly creates this view and ensures security by restricting access to sensitive data?

hard📝 Application Q15 of 15
SQL - Views
You want to create a view PublicEmployeeData that hides the Salary column from the Employees table but allows users to see EmployeeID, Name, and Department. Which SQL statement correctly creates this view and ensures security by restricting access to sensitive data?
ACREATE VIEW PublicEmployeeData AS SELECT EmployeeID, Name, Department FROM Employees;
BCREATE VIEW PublicEmployeeData AS SELECT * FROM Employees WHERE Salary IS NULL;
CCREATE VIEW PublicEmployeeData AS SELECT EmployeeID, Name, Department, Salary FROM Employees;
DCREATE VIEW PublicEmployeeData AS SELECT EmployeeID, Name FROM Employees;
Step-by-Step Solution
Solution:
  1. Step 1: Identify columns to include and exclude

    We want EmployeeID, Name, Department but NOT Salary to protect sensitive data.
  2. Step 2: Choose the correct SELECT statement for the view

    CREATE VIEW PublicEmployeeData AS SELECT EmployeeID, Name, Department FROM Employees; selects only the allowed columns, hiding Salary effectively.
  3. Final Answer:

    CREATE VIEW PublicEmployeeData AS SELECT EmployeeID, Name, Department FROM Employees; -> Option A
  4. Quick Check:

    View excludes Salary to secure sensitive data [OK]
Quick Trick: Select only non-sensitive columns in view to protect data [OK]
Common Mistakes:
MISTAKES
  • Including Salary column accidentally
  • Using WHERE Salary IS NULL which filters rows, not columns
  • Selecting too few columns missing Department

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes