当前位置:网站首页>基础-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):事务一旦提交或回滚,它对数据库中的数据的改变就是永久的。
事务隔离级别
边栏推荐
猜你喜欢
方法区里面有什么——class文件、class文件常量池、运行时常量池
The IE mode tab of Microsoft edge browser is stuck, which has been fixed by rolling back the update
cmake / set 命令
A list of common methods for customizing paint and canvas of view
String constant pool, class constant pool, and runtime constant pool
MySQL 11th job - view application
【Leetcode】76. Minimum covering substring
Detailed explanation of winsorflow quantum installation process
MySQL第十三次作业-事务管理
MySQL learning summary
随机推荐
1. 两数之和(LeetCode题目)
Control setting layout in linear layout_ Gravity doesn't work?
What should the preview do?
【无标题】
Extracting public fragments from thymeleaf
瑞萨电子面向物联网应用推出完整的智能传感器解决方案
[depth first search] 312 Poke balloon
【無標題】
[sans titre]
When will JVM garbage collection enter the older generation
MySQL第十二次作业-存储过程的应用
MySQL 13th job - transaction management
Establishment of smart dialogue platform for wechat official account
[untitled]
Glide's most common instructions
【LeetCode】59. 螺旋矩阵 II
Internationalization configuration
3行3列整形二维数组,求对角之和
美国总统签署社区安全法案以应对枪支问题
Retrofit common request methods and comments, post, get heard file upload