当前位置:网站首页>MySQL数据库(一)
MySQL数据库(一)
2022-07-05 05:17:00 【司小幽】
1.数据库简介
# 数据库内容: 存储数据的仓库,对数据库中的数据进行增删改查
# 数据表:具体存放数据的地方
2.常用的数据库
# Oracle:收费的大型数据库
# mysql:开源免费 小型
# sqlserver:收费的中型的数据库
# db2:收费的
3.操作数据库
# 鼠标操作 SQL语句操作
# SQL的代码:
# sql语法:
# 不区分大小写
# 每一句sql之后分号 a查询 b查询
4.数据库中常用的数据类型
# int类型 数字的类型
# varchar(50) 字符串 不定长 字节65535 男 2个字节
# char 字符串 定长的字节 255个字节 男 2个字节 空中
# date日期 格式'yyyy-mm-dd'
# datetime日期 格式'yyyy-mm-dd hh:mm:ss'
5.常用SQL操作
-- 注释ctrl+/ 加注释 多行注释/**/
-- 用sql语句创建数据库 语法: create database 数据库名
CREATE database ysly;
-- 删除数据库 语法:drop database 数据库名;
drop database ysly;
-- 新建表
-- 语法
/* create table 表名( 字段名 字段类型 约束条件, 字段名 字段类型, ... 字段名 字段类型 )charset=utf8; */
-- not null 主键primary key 自增 default
-- 设置了主键 主键不能空,自增一定要是主键
-- 你创建的这个表放在哪个数据里面
create table you.student1(
id int PRIMARY key auto_increment,
name varchar(20) default 'zz',
age int,
sex char(20)
);
-- 表里面的所有字段都要添加进去
-- 新增数据 语法结构 insert into 表名 values(字段名数据,字段名数据,字段名数据,字段名数据)
insert into you.student1 values(1,'小翠',18,'女');
insert into you.student1 values('小翠2',18,'女');
-- 只添加部分字段
-- insert into 表名(字段名,字段名,字段名)values(字段数据,字段数据,字段数据)
insert into you.student1(name,age,sex) values('小翠2',18,'女');
insert into you.student1(age,sex) values(18,'女');
-- 一次性添加多个数据 values value
-- insert into 表名 values(字段名数据,字段名数据,字段名数据,字段名数据),(字段名数据,字段名数据,字段名数据,字段名数据),(字段名数据,字段名数据,字段名数据,字段名数据)
insert into you.student1(name,age,sex) value('小红',18,'女'),('小红2',18,'女'),('小红3',18,'女'),('小红3',18,'女');
-- 查询语句
-- 查询 select * from 表名;
select * from you.student1;
-- 查询部分数据 select 字段名,字段名 from 表名
select id,name from you.student1;
-- 修改语句 update 表名 set 字段名 = 修改的内容 整个表的整个字段
update you.student1 set name = '翠花';
-- 不想修改整个表的字段 只想修改编号为1的名字 或者 年龄为18条件 where 加条件
update you.student1 set name = '酸菜' where id = 1;
update you.student1 set name = '紫菜' where age = 30;
-- 删除 delete from 表名;delete from 表名 where条件;
delete from you.student1 where id = 2;
delete from you.student1;
-- drop table 表名;表结构
drop table you.student1;
-- truncate table 表名;
truncate you.student;
边栏推荐
- [转]: OSGI规范 深入浅出
- [leetcode] integer inversion [7]
- To be continued] [UE4 notes] L4 object editing
- UE4/UE5 虚幻引擎,材质篇,纹理,Compression and Memory压缩和内存
- [to be continued] [UE4 notes] L3 import resources and project migration
- C语言杂谈1
- Ue4/ue5 illusory engine, material chapter, texture, compression and memory compression and memory
- 2022/7/2做题总结
- Chinese notes of unit particle system particle effect
- Cocos progress bar progresstimer
猜你喜欢

支持多模多态 GBase 8c数据库持续创新重磅升级

Reverse one-way linked list of interview questions
![[to be continued] [depth first search] 547 Number of provinces](/img/c4/b4ee3d936776dafc15ac275d2059cd.jpg)
[to be continued] [depth first search] 547 Number of provinces

十年不用一次的JVM调用

Unity find the coordinates of a point on the circle

UE4/UE5 虚幻引擎,材质篇(三),不同距离的材质优化

YOLOv5添加注意力機制

Romance of programmers on Valentine's Day

Stm32cubemx (8): RTC and RTC wake-up interrupt
![To be continued] [UE4 notes] L4 object editing](/img/0f/cfe788f07423222f9eed90f4cece7d.jpg)
To be continued] [UE4 notes] L4 object editing
随机推荐
Haut OJ 1350: choice sends candy
[allocation problem] 455 Distribute cookies
Generate filled text and pictures
Time format conversion
When will Wei Lai, who has been watched by public opinion, start to "build high-rise buildings" again?
[LeetCode] 整数反转【7】
Dotween usage records ----- appendinterval, appendcallback
2022/7/2 question summary
Unity check whether the two objects have obstacles by ray
cocos2dx_ Lua particle system
Count sort
room数据库的使用
对象的序列化
Haut OJ 1357: lunch question (I) -- high precision multiplication
Do a small pressure test with JMeter tool
[转]: OSGI规范 深入浅出
[merge array] 88 merge two ordered arrays
cocos_ Lua loads the file generated by bmfont fnt
Applet live + e-commerce, if you want to be a new retail e-commerce, use it!
Romance of programmers on Valentine's Day