当前位置:网站首页>基础-MySQL
基础-MySQL
2022-06-26 09:37:00 【伊木子曦】
DDL
数据库操作
show databases;
create databases;
use 数据库名;
select database();
drop database 数据库名;
表操作
show tables;
create table 表名(字段 字段类型 ,字段 字段类型);
desc 表名;
show create table 表名;
alter table 表名 add/rename to...;
alter table 表名 modify 字段名 新数据类型(长度);
alter table 表名 change 旧字段名 新字段名 类型(长度) [comment 注释][约束];
drop table 表名;
DML
insert into 表名(字段1,字段2..)values(值1,值2,..);
update 表名 set 字段1=值1,where 条件;
delete from 表名 where 条件;
DQL

DCL
用户管理
create user '用户名'@'主机名' identified by '密码';
alter user '用户名'@'主机名' identified with mysql_native_password by '密码';
drop user '用户名'@'主机名';
权限控制
grant 权限列表 on 数据库名.表名 to '用户名'@'主机名';
revoke 权限列表 on 数据库名.表名 from '用户名'@'主机名';
函数
字符串函数

数值函数

日期函数

流程函数

约束
1.非空约束:not null
2.唯一约束:unique
3.主键约束:primary key(自增:auto_increment)
4.默认约束:default
5.检查约束:check
6.外键约束:foreign key
多表查询
多表关系

多表查询

事务
事务是一组操作的集合,要么全部执行成功,要么全部执行失败。
start transaction;--开启事务
commit/rollback;--提交/回滚事务
四大特性ACID
原子性(Atomicity):事务是不可分割的最小操作单元,要么全部成功,要么全部失败。
一致性(Consistency) :事务完成时,必须使所有的数据都保持一致状态。
隔离性(lsolation):数据库系统提供的隔离机制,保证事务在不受外部并发操作影响的独立环境下运行。
持久性(Durability):事务一旦提交或回滚,它对数据库中的数据的改变就是永久的。
事务隔离级别
边栏推荐
- 1. 两数之和(LeetCode题目)
- 118. 杨辉三角
- Problems encountered in the application and development of Hongmeng and some roast
- Win10安装tensorflow-quantum过程详解
- 方法区里面有什么——class文件、class文件常量池、运行时常量池
- MySQL project 7 Summary
- Hcia-dhcp experiment
- 什么是僵尸网络
- Crawler related articles collection: pyppeter, burpsuite
- Record the handling of oom problems caused by too many threads at one time
猜你喜欢

MySQL job 11 - application de la vue

118. Yanghui triangle

【LeetCode】59. Spiral matrix II

开发者,微服务架构到底是什么?

創建對象的時候堆內存的分配

Selection of webrtc video codec type VP8 H264 or other? (openh264 encoding, ffmpeg decoding)

MySQL第九次作业-连接查询&子查询

Appium automation test foundation - mobile end test environment construction (II)

JS reverse | four libraries and one platform response data encryption

118. 杨辉三角
随机推荐
JSP file syntax
Basic string operations in C
创建对象的时候堆内存的分配
Recyclerview implements flow layout (LinearLayout with line wrap) (flexboxlayoutmanager)
Cloud native essay using Hana expression database service on Google kubernetes cluster
字符串常量池、class常量池和运行时常量池
How to find and install the dependent libraries of Debian system
Svn command
Flutter与原生通信(上)
Crawler related articles collection: pyppeter, burpsuite
【Leetcode】76. 最小覆盖子串
[binary search] 4 Find the median of two positive arrays
How do technicians send notifications?
六月集训(第26天) —— 并查集
【LeetCode】59. 螺旋矩阵 II
Little red book - Summary of internal sales spike project
String class intern() method and string constant pool
Establishment of smart dialogue platform for wechat official account
MySQL第五章总结
國際化配置