使用grant给student用户赋予表student,score的查询权限
时间: 2024-02-22 10:55:06 浏览: 39
可以使用以下命令来给student用户赋予表student和score的查询权限:
```
GRANT SELECT ON student TO student;
GRANT SELECT ON score TO student;
```
其中,第一个GRANT语句表示给student用户赋予对student表的查询权限,第二个GRANT语句表示给student用户赋予对score表的查询权限。最后的"TO student"表示将这些权限赋予给名为student的用户。
相关问题
使用grant给student用户赋予表student,score的查询权限。
可以使用如下的 SQL 语句给 student 用户赋予表 student 和 score 的查询权限:
```
GRANT SELECT ON database_name.student TO 'student'@'localhost';
GRANT SELECT ON database_name.score TO 'student'@'localhost';
```
其中,`database_name` 是你要授权的数据库名。`'student'@'localhost'` 是要授权的用户和主机名,这里指的是用户名为 student,主机名为 localhost。
执行完上述 SQL 语句后,student 用户就可以查询数据库中的 student 和 score 表了。
求代码 使用grant给student用户赋予表student,score的查询权限。
假设你正在使用MySQL数据库,可以使用以下代码将查询权限授予student用户:
```sql
GRANT SELECT ON database_name.student TO 'student'@'localhost';
GRANT SELECT ON database_name.score TO 'student'@'localhost';
```
其中,`database_name`是你的数据库名称,`student`是你要赋予权限的用户,`localhost`表示该用户只能从本地访问。
这将授予student用户在student和score表上的查询权限。如果你想授予更多的权限,可以在`GRANT`语句中添加其他关键字,例如`INSERT`、`UPDATE`等。
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)