当前位置:网站首页>基础-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):事务一旦提交或回滚,它对数据库中的数据的改变就是永久的。
事务隔离级别
边栏推荐
- Poj3682 king arthur's birthday celebration (probability)
- The fourteenth MySQL operation - e-mall project
- Global and Chinese market of contemporary lampshade 2022-2028: Research Report on technology, participants, trends, market size and share
- jar版本冲突问题解决
- [binary search] 4 Find the median of two positive arrays
- Call API interface to generate QR code of wechat applet with different colors
- Full introduction to flexboxlayout (Google official flexible implementation of flow layout control)
- The IE mode tab of Microsoft edge browser is stuck, which has been fixed by rolling back the update
- How to change the QR code material color of wechat applet
- 國際化配置
猜你喜欢

MySQL第十一作業-視圖的應用

Servlet learning notes II

About multi table query of MySQL

904. 水果成篮

Software testing - how to select the appropriate orthogonal table

MySQL job 11 - application de la vue

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

Automated testing -- Introduction and use of pytest itself and third-party modules

MySQL 13th job - transaction management

3行3列整形二维数组,求对角之和
随机推荐
Global and Chinese market of electronic pet door 2022-2028: Research Report on technology, participants, trends, market size and share
Allocation de mémoire tas lors de la création d'objets
Leetcode intermediate node of linked list
美国总统签署社区安全法案以应对枪支问题
The first batch of 12 enterprises settled in! Opening of the first time-honored product counter in Guangzhou
Index summary of blog articles -- Industrial Internet
A list of common methods for customizing paint and canvas of view
Configuration internationale
JVM垃圾回收什么情况会进入老年代
1. 两数之和(LeetCode题目)
瑞萨电子面向物联网应用推出完整的智能传感器解决方案
Small example of SSM project, detailed tutorial of SSM integration
【LeetCode】59. Spiral matrix II
MySQL Chapter 4 Summary
Global and Chinese market for change and configuration management software 2022-2028: Research Report on technology, participants, trends, market size and share
The fourteenth MySQL operation - e-mall project
Introduction to libmagic
Automated testing -- Introduction and example of pytest framework
动态库连接 - 符号冲突 - 全局符号介入
MySQL 13th job - transaction management