当前位置:网站首页>基础-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):事务一旦提交或回滚,它对数据库中的数据的改变就是永久的。
事务隔离级别
边栏推荐
- String class intern() method and string constant pool
- Cmake / set command
- Problems encountered in the application and development of Hongmeng and some roast
- Day 3 array, pre post, character space, keyword and address pointer
- Under the double reduction, the amount of online education has plummeted. Share 12 interesting uses of webrtc
- Appium automation test foundation - mobile end test environment construction (II)
- 2. 合并两个有序数组
- 904. fruit baskets
- Battery historian analyzes battery consumption
- Pytest configuration file
猜你喜欢

Standard implementation of streaming layout: a guide to flexboxlayout

方法区里面有什么——class文件、class文件常量池、运行时常量池

创建对象的时候堆内存的分配

cmake / set 命令

SSM项目小例子,SSM整合图文详细教程

MySQL第十三次作业-事务管理

jar版本冲突问题解决

Cloud native essay using Hana expression database service on Google kubernetes cluster

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

About multi table query of MySQL
随机推荐
Crawler related articles collection: pyppeter, burpsuite
Basic string operations in C
What is the web SSH service port of wgcloud
二叉树常见面试题
【LeetCode】59. Spiral matrix II
1. 两数之和(LeetCode题目)
Solution to the problem of compilation error due to repeated third-party package names
美国总统签署社区安全法案以应对枪支问题
MySQL project 8 summary
瑞萨电子面向物联网应用推出完整的智能传感器解决方案
Blog post index summary --c #
創建對象的時候堆內存的分配
2. 合并两个有序数组
P1296 whispers of cows (quick row + binary search)
Battery historian analyzes battery consumption
Automated testing -- Introduction and use of pytest itself and third-party modules
利用foreach循环二维数组
MySQL Chapter 6 Summary
Solution to network request crash in retrofit2.8.1
118. 杨辉三角