随笔分类 - MySQL
摘要:1 从哪个表,然后过滤掉一部分 from-where--group by--having 2 查询 select 3 对查询的结果数据进行排序 order by--asc/desc--limit
阅读全文
摘要:1 用户的创建 创建wangsiyu用户,只能在localhost这个服务器登录,密码是wangsiyu123 create user 'wangsiyu'@'localhost' identified by 'wangsiyu123'; 创建neha用户,可以在任意电脑登录,密码是nezha123
阅读全文
摘要:1 创建账户数据库表 CREATE TABLE account( id INT PRIMARY KEY AUTO_INCREMENT, name varchar(10), money DOUBLE ) 2 添加两条数据 insert into account(name,money) values (
阅读全文
摘要:1 用户创建 创建user1用户,只能在localhost这个服务器登录mysql服务器,密码123 create user 'user1'@'localhost' identified by '123'; 创建user2用户,可以在任意服务器登录mysql服务器,密码123 create user
阅读全文
摘要:1 转账,创建表并添加数据 create table account{ id int primary key auto_increment, name varchar(20) not null, money double }; 2 查看mysql是否开启自动提交事务 select @@autocom
阅读全文
摘要:#from——where——group by——having——select——distinct——order by——limit 代码块 select * from student where class='ec14' group by gender having age>18 order by
阅读全文
摘要:#1 多表查询:创建一个部门表和员工表并插入数据 代码块 use company; #创建部门表 CREATE TABLE department ( id int PRIMARY key auto_increment, dep_name varchar(10) not null ); #创建员工表
阅读全文
摘要:1 约束种类 约束名 | 约束关键字 :-:|:-: 主键|primary key 唯一|unique 非空|not null 外键|foreign key 检查约束|mysql不支持 2 主键约束 通常不使用业务字段(身份证,学号)作为主键,单独使用一个id作为主键,可以没意义,只要唯一,非空就行
阅读全文
摘要:1 排序 查询学生,先按年龄升序,再按照成绩降序 select * from student order by age asc,score desc; 2 聚合函数 查询学生总人数 select count(*) as 总人数 from student; 如果某一位置为null,可以使用IFNULL
阅读全文
摘要:#1 Navicat无法连接数据库的解决办法 打开【win+r】输入CMD进入命令行界面,然后输入 alter user 'root'@'localhost' identified by '密码' password expire never; alter user 'root'@'localhost
阅读全文
摘要:向来比较懒,能动嘴的坚决不动手,后来发现还是绝知此事要躬行,总结记录下mysql的知识点吧,凑合着看。 1 DDL数据定义语言 1-1 创建数据库 创建数据库db1 create database db1; 判断数据库是否存在 ,不存在则创建数据库 create database if not ex
阅读全文

浙公网安备 33010602011771号