-
Notifications
You must be signed in to change notification settings - Fork 0
user
Zhamri Che Ani edited this page Nov 4, 2024
·
6 revisions
These commands are typically used by database administrators (DBAs) to manage users, permissions, and roles in the database.
CREATE USER "zhamri" IDENTIFIED BY "zhamri123";- Grant System Privileges (e.g., creating tables, sessions):
GRANT CREATE SESSION TO "zhamri"; -- Allows user to log in
GRANT CREATE TABLE TO "zhamri"; -- Allows user to create tables- Grant Object Privileges (e.g., access to specific tables):
GRANT SELECT, INSERT, UPDATE ON "d1_student_realtime" TO "zhamri";- Grant Role (e.g., DBA role for full privileges):
GRANT DBA TO "zhamri";ALTER USER "zhamri" IDENTIFIED BY new_password;- Lock a user account to prevent login:
ALTER USER username ACCOUNT LOCK;- Unlock a user account to allow login:
ALTER USER username ACCOUNT UNLOCK;Delete a user and all associated objects:
DROP USER username CASCADE;List all users you have access to:
SELECT username FROM all_users;List all users (requires DBA privileges):
SELECT username FROM dba_users;SELECT USER FROM dual;List system privileges:
SELECT * FROM user_sys_privs WHERE username = 'USERNAME';List object privileges:
SELECT * FROM user_tab_privs WHERE grantee = 'USERNAME';REVOKE privilege FROM username;
REVOKE CREATE TABLE FROM username;