当前位置:网站首页>MySQL基础知识点总结
MySQL基础知识点总结
2022-06-28 09:25:00 【自律的西瓜L】
1.什么是数据库?
数据库是一个以某种有组织方式存储的数据集合。
理解数据库的一种最简单的办法就是将其想象成为一个文件柜。此文件柜是一个存放数据的物理位置,不管数据是什么以及如何组织的。
2.表的概念
表是某种特定类型数据的结构化清单。
关键点:存储在表中的数据是一种类型的数据或一个清单。决不应该将顾客的清单与订单的清单存储在同一个数据库表中。这样做会导致后面检索和访问很困难,应该创建两个表,每个清单一个表。
注意:数据库中每个表都有一个名字,用来标识自己。这个名字是唯一的。在不同的数据库中可以使用相同的表名。
3.不能部分使用DISTINCT
DISTINCT关键字应用于所有列而不仅仅是前置它的列。如果给出SELECT DISTINCT id,money,除非指定的两个列都不同,否则所有行都被检索出来。
4.MYSQL 5的LIMIT语法
LIMIT 3,4的含义不是太清楚,容易使人搞糊涂,它的意思是从行3开始的4行。但是容易记反
由于这个原因,MYSQL 5支持LIMIT的另一种替代语法。
LIMIT 4 OFFSET 3 意思是从行3开始取4行,就像LIMIT 3,4一样。
5.排序检索数据 order by
需要注意的一点是,经常需要按不止一个列进行数据排序。例如,如果要显示雇员清单,可能希望按姓和名排序(首先按姓排序,然后在每个姓中再按名排序)。
如果多个雇员具有相同的姓,这样很好用。
为了按多个列排序,只要指定列名,列名之间用逗号分开即可(就像选择多个列所做的那样)。
指定排序方向:
数据排序不限于升序排序(从A到Z)。这只是默认的排序顺序,还可以使用ORDER BY子句以降序(从Z到A)顺序排序。为了进行降序排序,必须指定DESC关键字。
6.不匹配检查
例子:列出不是303班同学的姓名 SELECT class_id,name From student WHERE class_id <> 303
注意:使用 != 和<> 效果是一样的。
7.计算次序
WHERE可包含任意数目的AND和OR操作符。允许两者结合以进行复杂和高级过滤。
SQL像多数语言一样在处理OR操作符前,优先处理AND操作符。
8.为什么要使用IN操作符?优点如下:
a.在使用长的合法选项清单时,IN操作符的语法更清楚且更直观;
b.在使用IN时,计算的次序更容易管理(因为使用的操作符少);
c.IN操作符一般比OR操作符清单执行更快;
d.IN的最大优点是可以包含其他SELECT语句,使得能够动态地创建WHERE子句。
边栏推荐
- Summary of PMP learning experience
- 异常处理4种方法
- When the interviewer asks you to write binarysort in two ways
- Screen settings in the source code of OBS Live Room
- 优秀笔记软件盘点:好看且强大的可视化笔记软件、知识图谱工具Heptabase、氢图、Walling、Reflect、InfraNodus、TiddlyWiki
- Calculation of stock purchase and sale expenses
- June 27, 2022: give a 01 string with a length of N. now please find two intervals so that the number of 1 is equal and the number of 0 is equal in the two intervals. The two intervals can intersect bu
- P2394 yyy loves Chemistry I
- Check whether the table contains rows SQL Server 2005 - check whether a table contains rows or not SQL Server 2005
- Which occupational groups are suitable for the examination
猜你喜欢

From knowledge to wisdom: how far will the knowledge map go?

Interpretation of new products: realm launched GT neo2 Dragon Ball customized version

Test cases for learning the basic content of software testing (II)

布隆过滤器 课程研究报告

Prototype chain JS

Data modeling based on wide table

P2394 yyy loves Chemistry I

Resource scheduling and task scheduling of spark

PMP Exam key summary VI - chart arrangement

Screen settings in the source code of OBS Live Room
随机推荐
线程和进程
Flip CEP skip policy aftermatchskipstrategy Skippastlastevent() matched no longer matches the Bikeng Guide
==和eqauls()的区别
Dbeaver连接人大金仓KingbaseES V8(超详细图文教程)
JVM family (2) - garbage collection
File operations in QT
English translation plug-in installation of idea
A classic JVM class loaded interview question class singleton{static singleton instance = new singleton(); private singleton() {}
How to reduce the risk of project communication?
Music website design based on harmonyos (portal page)
Abnormal occurrence and solution
Basic content learning of software testing (I)
浅谈小程序对传媒行业数字化的影响
两道面试小Demo
Interpretation of new products: realm launched GT neo2 Dragon Ball customized version
静态代码块永远先执行? 格局小了!!!
PMP考试重点总结八——监控过程组(2)
Static page of pinyougou mall
Dolphin scheduler uses system time
结巴分词器_分词器原理