当前位置:网站首页>Adding, deleting, querying and modifying MySQL tables (II)
Adding, deleting, querying and modifying MySQL tables (II)
2022-07-20 23:39:00 【51CTO】
One 、 Database Constraints
There are six :
- NOT NULL: Can't store NULL value
- UNIQUE:
- DEFAULT: The default value is given when there is no assignment
- PRIMARY KEY:
- FOREIGN KEY
- CHECK
summary :
- The default value is null Can pass default To modify the ;
- primary key Can't be empty , Can't repeat ;
- The auto increment primary key can be set to null, It can also be set manually ;
- When using foreign keys , When the parent table is empty , Cannot insert data into sub table ;
Two 、 Add and query
2.1、 Aggregate query
Aggregate functions :
- count( Name ): Return the number of data queried ;
- sun( Name ): Return the sum of the query data ;
- avg( Name ): The average value of the data returned to the query ;
- max( Name ): Return to the maximum value of the queried data ;
- min( Name ): Return to the minimum value of the queried data ;
2.2、 The joint query
The cartesian product :select * from Table name , Table name 2;
2.2.1、 Internal connection
2.2.2、 External connection
The outer connection is divided into left outer connection and right outer connection
2.2.3、 Self join
2.2.4、 Subquery
2.2.5、 Merge query
summary :
- When there are multiple tables for conditional filtering , First join, In the after on Add filter criteria later ;
- The inner connection represents the data shared by two tables , The left outer connection indicates join The data on the left contains , The right outer connection indicates join The data on the right contains ( If it doesn't work null Add );
- When self connecting , You need to alias the table ;
- Subquery has only one result ‘=’, Multiple results ‘in’;
- union duplicate removal ,union all No weight removal ;
边栏推荐
猜你喜欢
cnpm安装
簡單斐波那契
[swintransformer source code reading 1] build_ Loader part code
微信小程序接入微信支付流程
企业数字化转型之传统架构到中台微服务架构
【云原生】 iVX 低代码开发 引入腾讯地图并在线预览
微信和QQ都能正常上网,但网页不能上网的3种解决办法。
阿里P8晒1月工资条,看完真的狠狠扎心了…
【软考软件评测师】2015综合知识历年真题
[dbeaver] a detailed tutorial on the installation and use of official software, easy to use and free open source tools
随机推荐
01_教育4
微信小程序接入微信支付流程
几种2022年流行的跨端技术方案的优缺点
ArrayList基础案例
Simple Fibonacci
面试题 08.07. 无重复字符串的排列组合-dfs法
【大规模训练】transformer 中的张量模型并行
Rust开发——Trait的概念与应用示例
RuntimeError: CUDA error: an illegal memory access was encountered
404 page best practices to improve user experience
Camtasia 2022新版本发布CS喀秋莎2022功能亮点
mysql之select查询篇2
RuntimeError: CUDA error: an illegal memory access was encountered
簡單斐波那契
lvgl 之常见配置项修改
【SwinTransformer源码阅读一】build_loader部分代码
I really can't roll
力扣第五天
Scaffold cli3
[ROS] handwritten message publisher and subscriber