当前位置:网站首页>数据库笔记整理
数据库笔记整理
2022-07-15 16:26:00 【.Null】
知识点总结:
数据库:
作用(相比excel):
安全性(用于服务器):
读写、查询能力(效率):
MySQL:概念:关系型数据库(一个或多个表格)。
表头(header)、行(row)、列(col)、值(value)、键(key);数据类型:
数字类型:(整型和浮点型)
日期和时间:(data、time、datatime等)
字符串类型:(字符串、文本和二进制等)关键字:(NULL、NOT NULL、DEFAULT等)
使用数据库:
1)登陆到MySQL:
2)创建一个数据库:create databases 数据库名; -> show databases;
3)选择所要操作的数据库:use 数据库名;
4)创建数据库表:create table 表名称(列声明);
5)删除数据库表:drop database 数据库名;操作数据库(与SQL相差无几):
1)向表中插入数据:insert into 表名 values();
2)查询表中的数据:select 列名 from 表名 [查询条件];
Select * from 表名;
DISTINCT关键字:取不重复的;
Like/Not like
3)按特定条件查询:select * from 表名 where 条件;((where name like “%王%”))
4)更新表中的数据:update 表名 set 列名称=新值 where 更新条件;
5)删除表中的数据:delete from 表名 where 删除条件;
总结:增(insert into…values…)、删(delete from…where…)、改(update…set…where…)、查(select * from…where…)。
排序创建表后的修改:alter table …change/add/drop/rename/
添加列、修改列、删除列、重命名表、删除整张表、删除整个数据库:
SQL高级进阶:
1)like: 2)In: 3)Between: 4)链接:inner join、left join、right join、full join 5)SQL函数:
Aggregate函数(聚类函数):avg()/count()/first()/last()/min()/sum()
Scalar函数(标量函数):ucase()大写/lcase()小写/mid()提取字符 /substring(1,end)/len()/round()四舍五入/now(日 期)/format()格式化
数据库工具: MySQL WorkBench
创建数据库 -> 创建表 -> 存入数据 -> 读取数据(操作)
10、说明:几个简单的基本的sql语句
选择:select * from table1 where 范围
插入:insert into table1(field1,field2) values(value1,value2)
删除:delete from table1 where 范围
更新:update table1 set field1=value1 where 范围
查找:select * from table1 where field1 like ’%value1%’ —like的语法很精妙,查资料!
排序:select * from table1 order by field1,field2 [desc]
总数:select count as totalcount from table1
求和:select sum(field1) as sumvalue from table1
平均:select avg(field1) as avgvalue from table1
最大:select max(field1) as maxvalue from table1
最小:select min(field1) as minvalue from table1
from(表)+连接查询
连接查询
• 内连接:Inner join
• 左连接:Left join
• 右连接:Right join
内联查出这两个表中共有的信息(as为表的别名,方便).
左外连接:左表的值会全部显示出来,右表的值显示on条件搜索的的结果,搜索不到为NULL.
右外连接与左外连接相反(右表的值全部显示出来).
边栏推荐
- 函数高级应用
- flink. 14. How is the underlying layer of datastream module source implemented?
- Grafana Labs携手阿里云,将提供国内首款Grafana托管服务
- leetcode:240. 搜索二维矩阵 II
- canal实现从mysql实时同步数据到es
- 赋能新工业,制造新未来 | 图扑软件受邀参加厦门工业博览会
- 迪文串口屏教程(2)
- The third question of the 13th Landbridge cup 2022 - sum (prefix sum or formula method)
- Animation and encapsulation (offset, client, scroll series)
- 不能不知道的分布式基础理论
猜你喜欢

CS5801_ HDMI to EDP advantage replaces lt6711a solution

Face the object

Application du moteur de visualisation Web de topologie dans le domaine de la simulation et de l'analyse

迪文串口屏教程(1)

一致性协议之2PC和3PC

從數字化到智能運維:有哪些價值,又有哪些挑戰?

【LeetCode】26、删除有序数组中的重复项

Function advanced application

函数与箭头函数

如何將notepad++設置為默認打開方式
随机推荐
leetcode:74. 搜索二维矩阵
What is the difference between reject and catch processing in promise
MySQL数据库在触发器中定义游标
论文中的好文佳句摘录
因员工将密码设为“123456”,AMD 被盗 450Gb 数据?
杰理之内置触摸可供修改的参数【篇】
Notes on Linear Algebra 1
vi编辑器命令
那些年我们用过的分布式锁,你都get到了吗
Matlab-mex
Functions and symbols
ECCV 2022 | 多域长尾分布学习,不平衡域泛化问题研究(开源)
flink. 14. How is the underlying layer of datastream module source implemented?
The difference between Es5 and ES6
Jerry's n turns on the 1-2 function, which will affect the Bluetooth distance [article]
MySQL CREATE TABLE statement error: 1103 incorrect table name
2、Deep Learning in Higher Dimensions
杰理之本修改解码时钟的方法【篇】
LeetCode 188. 买卖股票的最佳时机 IV***(double,need triple)
let / const /var的区别