Câu hỏi phỏng vấn MySQL
Câu hỏi

Explain GRANT command in MySQL

Câu trả lời

The GRANT command in MySQL is a powerful SQL statement used by database administrators to assign specific privileges to user accounts and roles within the MySQL database management system. This command is essential for controlling access to the database by specifying what operations a user can perform.

Overview of the GRANT Command

The basic syntax of the GRANT command is as follows:

sql Copy
GRANT privilege_list ON object TO user [WITH GRANT OPTION];
  • privilege_list: This is a list of privileges that you want to grant. These privileges could include actions like SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, etc. You can also use ALL PRIVILEGES to grant all standard privileges at once.
  • object: This specifies the database object to which the privileges apply. It can be a database, table, or a column, and is typically expressed in the format database.table or *.* for all databases and tables.
  • user: This defines the user account or role to which the privileges are being granted. It usually includes the username and host in the format 'username'@'host'.

Key Features and Options

  1. Privilege Types: MySQL supports various types of privileges that can be granted, ranging from data manipulation operations like SELECT, INSERT, UPDATE, and DELETE to database operations like CREATE, ALTER, and DROP. There are also administrative privileges like GRANT OPTION and SUPER[1][2][4].

  2. Privilege Levels: The GRANT command allows privileges to be set at different levels including global, database, table, column, and routine levels. For example, granting privileges on *.* applies globally across all databases and tables, while database.* applies to all objects within a specific database[2][4].

  3. WITH GRANT OPTION: This clause allows the user receiving the privileges to subsequently grant those privileges to other users. It is a critical feature for administrators who need to delegate authority within a team[1][4].

  4. *...

middle

middle

Gợi ý câu hỏi phỏng vấn

junior

What is the difference between TRUNCATE and DELETE ?

middle

What are REPEAT , LOOP and WHILE statements used for?

junior

What is Primary Key Constraint and Unique Key Constraints?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào