当前位置:网站首页>第6天总结&数据库作业
第6天总结&数据库作业
2022-07-26 08:41:00 【xbxbgk】
1.数据库的分类
关系型:mysql,oracle,sqllite(移动端自带的,django默认),sql server
非关系型:redis,mongoDB
2.mysql安装
保证:安装之前检查电脑是否安装过,卸载 mysql5.5版本,django使用5.5以上
数据库是用于存储数据
库/表 库类似目录 表类似目录中excle
3.基本知识点
sql语句
专门用于操作库和表的 重点
sql语句的分类
数据库查询语言(DQL) select
数据库操作语言(DML) delete update insert
数据库定义语言(DDL) 创建、删除、修改表的结构 create、drop、alter
字段类型
整数:int/bigint
小数:float/double
字符串:char/varchar
时间:date/time/datetime
字段的约束
null 可以为空
not null 不能为空
default 默认值
primary key 主键
auto_increment 自增
charset 设置字符集
4.DDL数据库定义语言
创建库
create database 库名 CHARSET=utf8;
删除库
DROP DATABASE 库名;
查询创建的库的语句
show create DATABASE 库名;
使用库
use 库名
创建表
create table 表名(字段 类型 长度,字段 类型 长度)
删除表
drop table 表名
查询创建表的语句
show create table 表名;
查询表的结构
desc 表名
修改表结构
新增:alter table 表名 add 字段名 类型 长度;
修改:alter table 表名 MODIFY COLUMN 字段名 类型 长度;
删除: alter table 表名 drop 字段名;
5.DML数据库操作语言
新增
insert into 表名 value (值,值,值,值), (值,值,值,值)
修改
UPDATE 表名 set 字段=新值 where 条件 修改一个字段的数据
UPDATE 表名 set 字段=新值,字段=新值 where 条件 修改二个字段的数据
删除
delete from 表名 where 条件 删除指定数据
delete from 表名 删除全部数据
6.DQL数据库查询语言
查询全部的数据:select * from 表名;
查询指定字段的数据:select 字段名,字段名 from 表名;
比较运算符: > >= < <=
select * from 表名 where 字段 >值;
逻辑运算符:and or not
SELECT * from student where sex='女' and score>92
SELECT * from student where sex='女' or score>92
SELECT * from student where sex='男'
SELECT * from student where not sex='女'
关键字--模糊查询
select * from 表名 where 字段 like '%模糊数据%'
eg:%:匹配全部数据 _:代表匹配一个字符
范围查询 80~95
在...之间 在....里
SELECT * from student where score BETWEEN 80 and 95;
SELECT * from student where id in(1,3,5,7)
排序
select * from 表名 order by 字段 desc(倒序),字段 desc(倒序)
分组
函数:count() 查询数量 sum()和 max()取最大 min()取最小 avg()平均数
select count(*) from 表名 group by 字段 having 条件
eg:having 类似where 但是一般where后面不能和函数一块使用,having可以经常和group by一块使用
分页
limit 起始索引位置,显示的条数
SELECT * from student LIMIT 0,3
作业1

作业2

作业6

作业7

增删改查

边栏推荐
- Neo eco technology monthly | help developers play smart contracts
- Does flinkcdc now support sqlserver instance name connection?
- Xshell batch send command to multiple sessions
- TypeScript版加密工具PasswordEncoder
- SSH,NFS,FTP
- Flutter text is left aligned with no blank space in the middle
- Logic of data warehouse zipper table
- Flutter custom player progress bar
- Memory management based on C language - Simulation of dynamic partition allocation
- C Entry series (31) -- operator overloading
猜你喜欢
![[database] gbase 8A MPP cluster v95 installation and uninstall](/img/56/c0dae30ba608842c1b92e914ef42fe.png)
[database] gbase 8A MPP cluster v95 installation and uninstall

Spark persistence strategy_ Cache optimization

Pan micro e-cology8 foreground SQL injection POC

Registration of finite element learning knowledge points

基于C#实现的文件管理文件系统

Using the primitive root of module m to judge and solve

Excel find duplicate lines

OA项目之我的会议(查询)

Poor English, Oracle OCP or MySQL OCP exam can also get a high score of 80 points
![[untitled]](/img/89/c3ab79eb325f0136114a568745924b.png)
[untitled]
随机推荐
Logic of data warehouse zipper table
Flutter WebView jitter
Cadence(十)走线技巧与注意事项
Grid segmentation
正则表达式:判断是否符合USD格式
The lessons of 2000. Web3 = the third industrial revolution?
Vision Group Training Day5 - machine learning, image recognition project
23.8 using the applicationrunner or commandlinerunner to implement applicationrunner and commandlinerunner
P3743 kotori的设备
Web3 Games: current situation and future
合工大苍穹战队视觉组培训Day5——机器学习,图像识别项目
[encryption weekly] has the encryption market recovered? The cold winter still hasn't thawed out. Take stock of the major events that occurred in the encryption market last week
File management file system based on C #
Solve the problem of C # calling form controls across threads
Does flinkcdc now support sqlserver instance name connection?
Winter vacation homework & Stamp cutting
[C language] programmer's basic skill method - "creation and destruction of function stack frames"
Registration of finite element learning knowledge points
Study notes of automatic control principle --- stability analysis of control system
Alphabetic string