Introduction
SQL security awareness helps protect data from unauthorized access and keeps information safe.
-- SQL security is about controlling who can do what in the database. -- Common commands include GRANT and REVOKE to manage permissions. GRANT permission_type ON object TO user; REVOKE permission_type ON object FROM user;
GRANT SELECT ON Employees TO User1;
REVOKE INSERT ON Employees FROM User1;
GRANT ALL PRIVILEGES ON Database1.* TO AdminUser;CREATE TABLE Customers ( ID INT PRIMARY KEY, Name VARCHAR(100), Email VARCHAR(100) ); GRANT SELECT ON Customers TO ReadOnlyUser; -- Check permissions for ReadOnlyUser -- (This depends on your SQL system; here is an example for PostgreSQL) SELECT grantee, privilege_type FROM information_schema.role_table_grants WHERE table_name = 'customers' AND grantee = 'readonlyuser';
REVOKE UPDATE ON employees FROM user_john;GRANT SELECT, INSERT employees TO user_anna;Pass the test and this pattern moves unknown