杨超林 发表于 2021-11-24 18:57:28

多表连接,权限管理

内连接:select * from 表 inner jion 表 on 表.字段=表.字段;左连接:select * from 表left jion 表 on 表.字段=表.字段;右连接:select * from 表 right jion 表 on 表.字段=表.字段;基本连接: select * from 表,表 where 表.字段=表.字段;硬连接;select * from 表union select * from 表;嵌连接:select * from ()where条件;嵌套=方法:select* from 表 where 字段=();嵌套in方法:select * from 表 where 字段in();基本连接方法:select * from 表,表 where 表.字段=表.字段 and 条件; insert into user(host,user,password)values(‘localhost’,’dcs10’,password(‘123456’)); 往user表插入一个dcs10使用password这个函数对密码进行加密处理select host,user from user;插入之后再查询user表是否存在dcs10用户flush privileges; 插入用户之后,刷新权限show grants for ‘dcs10’@’localhost’; 查看dcs10 用户有哪些权限USACE 显示USACE表示没有任何操作权限grant select,drop,update,delete,create on *.* to ‘dcs10’@’localhost’ identified by’123456’;给dcs10用户赋予 查询,删表,更新,删数据,创建的权限 第一个表示所有的库;第二个表示所有的表;即针对所有库里面所有表grant all privileges on *.* to ‘xiaowang’@’%’identified by ‘123456’; 授予一个普通用户xiaowang及密码为123456,允许其可以通过所有客户机访问本数据库下所有的库及所有的表,假如为localhost只能在本地进行访问。show grants for ‘wang’@’%’;//查看数据库的指定授权用户的权限revoke all on *.* from ‘dcs’@;//取消所有权限revoke all on *.* from ‘dcs10’@’localhost;在root用户窗口移除dcs10用户所有权限delete from user where user=’zhongguo’and host=’localhost’;删除用户update user set password=password(‘123456’)where user=’root’;修改root用户的密码grant all privileges on *.* to ‘dcs11’@’localhost’ identified by’654321’;创建用户dcs11的同时赋予所有权限update user set password=password(‘654321’) where user=’dcs11’;把用户dcs11的密码更新为654321select version();查询数据库版本select now();查询数据服务器的当前时间select database();查询当前使用的是哪个数据库select user();查询当前登录用户
页: [1]
查看完整版本: 多表连接,权限管理