Navicat forMysql
第一次使用:第一步打开之后需要注册 老师发的有一个Key文件 打开复制里面的东西 然后粘贴在注册码那里
点击连接连接名 随便起 ip地址 :localhost 账号密码 输入就ok 填完之后要测试 确定没问题 就OK
点击用户 会显示root@1
root@127.0.0.1
root@localhost...
将1 改成% 就可以让所有人都访问你的数据库
破解cmd5 可以去cmd5 网站破解root密码
权限文件 /pgpStudy /Mysql/data/mysql
查询语句
查询所有select * from hello
查询成绩大于90的人数并且以部门分类:select dept,count(*) from hello where score>90 group by dept;
查询成绩大于90的人数并且以部门分类 每个部门人数不小于3:elect dept,count(*) as num from hello where score>90 group by dept having num >3;
关键词
distinct 用于返回唯一不同的值
selelct distinct dept form user
all 显示所有
group by 后面不可以继续条件判断 可以使用having (支队分组数据进行筛选)
desc(倒叙)asc(顺序)
比较操作符
is null 为空
between and
查询成绩在85~90之间的数字(包含85和90) select * from member where score between 85 and 90;
like:模糊匹配
select * from member where username like '3';
'%3%':字符串中包含3'%3':以3结尾'3%':以3 开头
in a n(b1,b2,b3)其中一个
select * from where in(90);
where 按条件
and && :逻辑与 or ||:逻辑或
xor select true xor true 结果:false
not 或 ! 逻辑非:
order by 排序 desc(倒叙)asc(顺序)
select * from hello order by score,sex;
当score 相等 可以参考第二顺序位
limit 用户将取得的数据按指定的行输出 从第几行开始取出多少行
注意 :
起始行号从0开始计算
2更id没有关系
3 要去除的的行数也是数字 要大于0
4简略形式limit行数==limit0 行数
select * from hello limit 0,3 = limit 3
连接查询
select * from hello as one inner join word as two on one.id = two.id
left 以左表为准 right 以右表为准
innner **
select top 3 * from hello --sqlserver
select * from hello wherer woenun --Oracle
子查询
select * from hello id in (select id from hello where score<90)
联合查询
将两个具有相同字段数量的查询结果 上下堆叠
select id,usernmae from hello union select id,unsername from world;
注意 两个查询字段数必须一致 字段类型一致 自动去掉重复行
创建用户
create user "用户名"@"允许登录地址/服务器" identified by '密码'
create user 'stu'@'192.168.17.10' identified by '123456'
删除用户
drop user 'stu1'@''192.168.17.10'
修改用户名:
set password = password(密码)
set password for 'stu'@'127.0.02' = 'password'('654321')
权限:
添加权限:
grant 缺陷列表 on 库名.对象名 to ‘用户名’@'登陆位置'
grant select,updata,insert,delete on zheshiku.hello to 'stud'@'%';
特殊语法:
*.*:代表所有数据库中所有下级单位
某库.*:某库中的所有下级单位
取消权限:
revode 权限列表 on 库名。对象名 from '用户名'@'登录位置'
revoke drop on zheshiku.hello to 'stud'@'%';
事物特点:
原子性
一致性
隔离性
持久性
自动提交模式:
关闭 set auto_commit = 0
人为提交 commit
事务执行的流程
bdgin;
inser into hello(username,password telphone) values ('asdf','sdf','123');
rollback;