当前位置:网站首页>mysql数据库
mysql数据库
2022-07-22 09:57:00 【yangdachaoa】
基础查询:
1,去除重复: distinct
2,计算列:
一般可以使用四则运算计算一些列的值。
ifnull(表达式1,表达式2):null参与的运算,计算结果都为null
3,运算符:
1.>、<、<=、>=、=、<>、!=
2.BETWEEN...AND
3.IN(集合)
4.LIKE: 模糊查询
4.1._:单个任意字符
4.2.%:多个任意字符
5.IS NULL
6.And或&&
7.OR 或 ||
8.Not 或 !
4, 约束
1)主键约束:primary key
1.1: 添加主键约束alter table 表(temp) add primary key 字段(id);
1.2:-- 删除主键约束alter table 表(temp) drop primary key;
2)唯一约束:Unique
1.1:添加表之后添加约束:Alter table 表(emp) modify 字段 (id) 类型(varchar(32))unique
1.2:删除唯一约束:alter table 表(emp) drop index 字段(id)
3)非空约束:not null
4)外键约束:foreign key
1.1: 添加外键约束:Alter table 表(emp) add constraint 外键名称 foreign key 外键字段名称(dep_id) references 主表名称(主表列名称)
1.2: 删除外键约束:alter table 表名 drop foreign key 外键名称;
5,事务的四大特性:
1)原子性:是不可分割的最小操作单位,要么成功,要么都不成功
2)持久性:当事务提交或回滚后,数据库会持久化的保存数据
3)隔离性:多个事务之间,相互独立
4)一致性:事务操作前后,数据总量不变
6,InnoDB与MYISAM区别
1)InnoDB支持事务,MYISAM不支持事务;对于InnoDB每一条sql语言都默认封装成事务,自动提交,这样会影响速度,最好把多条sql语句放在begin和commit之间,组成一个事务。
2)InnoDB支持外键,MYISAM不支持;对一个包含外键的InnnoDB表会转为MYISAM会失败;
3)InnoDB是聚集索引,使用b+tree作为索引。MyISAM是非聚集索引,
3.1聚集索引主键是数据跟索引是在一起的; 非聚集索引他是分开存储的;
边栏推荐
- 7.17 minimum ticket price
- Terminal data protection of Internet communication security
- Force deduction solution summary 1175 prime number arrangement
- Day4:循环结构
- 关于红队方面的学习资料
- Neo4j - Cypher 语法示例
- 干货分享-作为Lead 接手一个新的数据团队一 问题盘点 与Insights的发现
- Pytest interface automated testing framework | pytest installation and rules
- Grafana panel - modify visual text and background colors
- LeetCode刷题笔记
猜你喜欢
Terminal data protection of Internet communication security
Scope and lifecycle of beans
[learn C and fly] Chapter 3 branch structure (exercise 3.1 simple guessing game)
Mail Informer
Batch check crawler
Introduction to date object
相比技术与产品 倾听与意见才是Web3当下的首要任务
Connectivity of digraph
About human resource outsourcing companies
The strongest screen tool sharex v14.0.1
随机推荐
Encryption and decryption of 535 tinyurl
Doctoral application | Professor Ni Zhuoxian of the University of Hong Kong enrolls doctoral students with the full award in the direction of Internet of things and machine learning
CV520国产替代CI520非接触式读写器读卡芯片
博士申请 | 香港大学倪卓娴教授招收物联网与机器学习方向全奖博士生
CCF 1-2题答题记录(2)
Grafana panel - override field values
Delphi中巧用命令行参数实现拖拽文件到程序图标上触发功能
相比技术与产品 倾听与意见才是Web3当下的首要任务
Force deduction solution summary 814 binary tree pruning
Neo4j - Cypher 语法示例
PHP Cookie
NLP text classification top meeting paper reading notes for natural language processing (2)
Force deduction solution summary 1108-ip address invalidation
Markdown数学公式语法
Pytest interface automated testing framework | why do you want to do the secondary development of pytest plug-ins
pytest接口自动化测试框架 | 接口自动化至yaml数据驱动
firewall-cmd 常用操作命令
Force deduction solution summary 324 swing sequencing II
Day3:分支结构
[take you to learn C, take you to fly] branch structure in Chapter 3 of C language programming (3rd Edition) of Zhejiang University Edition (exercise 3)