mysql--DML--视图,索引,事务,字符集,函数

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介:
复制代码
Mysql中,表/列可以改名,database不能改名.
phpMyAdmin似乎有这功能? 他是建新库,把所有表复制到新库,再删旧库完成的.

删除一个数据库: drop database 数据库名;

创建一个数据库: create database 数据库名 [charset 字符集]

查看一下所有的库,怎么办?
Mysql>Show databases;
选库语句: Use 库名

删除表: drop table stu;



mysql> create table t1(id int,name varchar(10));
mysql> desc t1;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | YES  |     | NULL    |       |
| name  | varchar(10) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
mysql> show create table t1;
+-------+--------------------------+
|Table  | CreateTable               |
+-------+--------------------------+
| t1    | CREATE TABLE `t1` (
  `id` int(11) DEFAULT NULL,
  `name` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+--------------------------+

//表的列,3大类,
数值型(全数字):
    整型:int,存储数字1占据4个字节,32位00000000 00000000 00000000 00000001,最大2^32-1(42多亿),有符号的-2^31-----2^31-1,
    TINYINT:一个字节8位,0-255-128-127SMALLINT:2个字节,0-65535,
    MEDIUMINT:3个字节
    INT:4个字节
    BIGINT:8个字节
    zerofill M : zerofill适合于学号编码等固定宽度的数字,可以用0填充至固定宽度,M是填充值多宽。
    
    浮点型:float(M,D)[UNSIGNED][ZEROFILL],M总位数,D是小数点后几位 。  double大小不一样而已。
    
    定点型decimal:更精确。

字符串:char(定长),varchar(变长),text,
    char(10)最大存10个字符,只给1个字符还是给10个字符长度,内部用空格补充,取出时右侧空格删除。
    varchar(10)最大10个字符,只给1个字符,还有一个额外数字标注varchar的长度。
    20个字符以下用char,以上用varchar.速度上定长会快些。char最大255,varchar最大6万多。
    text,mediumtext,longtext:可以存60000多字符,
    blob,mediumblob,longblob:二进制的,不存图像几乎不用blob,不用考虑字符集了,
    ENUM枚举:性别,
    set(集合):
    
日期时间:2012-11-11143612
    YEAR1985)一个字节,Date(1998-12-11), Time(13:13:55),datetime(1998-12-13 13:56:09), 时间戳timestamp,

mysql> alter table t1 add unum tinyint unsigned;
mysql> insert into t1 values (1,'dvdfv',255);
mysql> alter table t1 add number tinyint(6) zerofill;//6位并且0填充,并且是无符号的。
mysql> alter table t1 add gender enum('','','');
mysql> insert into t1 values ('ffr','');
//NULL查询不方便,避免值为null,
create table t2 (id int not null default 0,name char(10) not null default '');

//主键:
mysql> create table t1 (id int not null primary key,name char(10) not null default '');
create table t1 (id int primary key auto_increment,name char(10) not null default '');

//表设计:定长不定长分离,常用不常用分离。

mysql> alter table temp drop column name;
mysql> alter table temp add name2 int not null default 0 after subject;
mysql> alter table temp change name11 name111 varchar(3) default '---';

----------------------------------------------------------------------------------------------------

//视图 : 虚拟表也是sql的查询结果,可以隐藏数据,视图存储的是单纯的语句,把建视图的语句和查视图的条件合并成查表的语句。也有可能视图语句比较复杂,很难和查询视图的语句合并,mysql可以先执行视图的创建语句,在内存中形成临时表,然后去查询临时表。
mysql> create view good_view as select goods_id,goods_name ,(market_price-shop_price) as less from goods limit 1 , 10;
mysql> select * from good_view;

mysql> show tables;//可以把视图查出来,视图和表对人来说没有区别,表改变视图也改变,
视图能不能更新删除添加:视图的每一行与物理表一一对应则可以。视图的行是由表多行经过计算的结果则不行。

create algorithm = merge view v7 as select * from goods;//这样每次查视图的时候就是去拼接语句然后查表

create algorithm = temp view v7 as select * from goods;//这样视图就是一个临时表

create view v7 as select * from goods;//让数据库自己判断方式

drop table t1;//删除视图
drop view goods_v;//删除视图
mysql> desc good_view;//查看视图的表结构
mysql> show table status;//查看表的详细信息
mysql> show table status where name = 'temp';//查看哪张表的详细信息
mysql> rename table temp to temptemp;//改表的名字
mysql> delete from temptemp where score = 90;//删除数据

Truncate和delete区别:Truncate是删除一张表再重新建立一张表,自增涨的信息也没了。delete之后自增涨信息还有。
删除表: drop table stu;

goods.frm:声明表的结构,建表时每一列是什么属性
goods.MYD:表内容
goods.MYI:索引信息
这3个文件有的没有,是因为引擎不一样,不指定引擎时现在默认是innodb,

乱码:字符集不一样,例如客户端是GBK的字符集(发送和接收的都是GBK),DB是utf8的(发送和接收的都是Utf8的),中间就要有一个连接转换器。
mysql> set character_set_results=gbk;//设置返回结果的结果集的字符集
mysql> select * from temp;
+---------+-------+-------+---------+------+
| subject | name2 | score | name111 | name |
+---------+-------+-------+---------+------+
| ����    |     0 |    50 | 0       |    0 |
| Ӣ��     |     0 |    40 | 0       |    0 |
+---------+-------+-------+---------+------+
mysql> set character_set_results=utf8;
mysql> select * from temp;
+---------+-------+-------+---------+------+
| subject | name2 | score | name111 | name |
+---------+-------+-------+---------+------+
| 语文    |     0 |    50 | 0       |    0 |
| 英语    |     0 |    40 | 0       |    0 |
+---------+-------+-------+---------+------+

mysql> set character_set_client=gbk;//设置客户端的字符集,cmd窗口就是客户端,
mysql> set character_set_results=gbk;//设置结果集的字符集
mysql> set character_set_connection=gbk;//设置连接器的字符集

-------------------------------------------------------------------------------------------------

索引;数据的目录,能快速定位行所在的位置。
索引文件:树形结构,加速查找,降低了增删改的速度。一般在查询频繁的列上加,在重复率低的列上加。有可能索引文件比数据文件还要大。

索引的创建原则:
1:不要过度索引
2:在where条件最频繁的列上加.
3:尽量索引散列值,过于集中的值加索引意义不大.

key:普通索引,加快查询速度,
unique:唯一索引,加快查询速度,还能约束数据(数据不能重复)
primary:主键索引, 不能重复,把主键当成索引,唯一索引不一定是主键,主键必唯一,但是一张表上,只能有一个主键, 但是可以用一个或多个唯一索引.
fulltext :全文索引中文无效,英文环境下可以针对值中的某个单词,一般用第三方解决方案。

mysql> create table index_t(name char(10),email char(20),key name(name),unique key email(email));//建表的最后,给name加普通索引,索引的名字就叫name,给email加唯一索引名字叫email,

mysql> desc index_t;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| name  | char(10) | YE   | MU  | NULL    |       |
| email | char(20) | YE   | UN  | NULL    |       |
+-------+----------+------+-----+---------+-------+
mysql> select * from index_t;//unique key 列不能重复
+------+--------------+
| name | email        |
+------+--------------+
| lisi | loisi@q.com  |
| lisi | liwu@q.com   |
+------+--------------+

mysql> create table t1(id int,name varchar(20),email varchar(20),primary key(id),key name(name),unique key email(email));//主键索引,

mysql> desc t1;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | NO   | PR  | NULL    |       |
| name  | varchar(20) | YE   | MU  | NULL    |       |
| email | varchar(20) | YE   | UN  | NULL    |       |
+-------+-------------+------+-----+---------+-------+

create table test5 (
    id int,
    username varchar(20),
    school varchar(20),
    intro text,
    primary key (id),
    unique (username),
    index (school),
    fulltext (intro)
) engine myisam charset utf8;
 
 
比如邮箱,只有前几个字符不同,后面都差不多的,可以只截取某一列的前几个字符然后建索引。
mysql> create table t1(id int primary key , email varchar(10), unique key email(email(3)));

多列索引,把多列看成一个整体,建立索引。
create table t1 (xing char(2),ming char(10), key xm(xing,ming));

mysql> select * from  t1 where xing = '姚闻' ;
+------+------+-----+
| xing | ming | zzz |
+------+------+-----+
| 姚闻 | 文文 |     |
+------+------+-----+
mysql> explain select * from  t1 where xing = '姚闻';//查看索引是否发挥作用
+----+-------------+-------+------------+-------+---------------+------+---------+-------+------+----------+-------+
| id | select_type | table | partitions | type  | possible_keys(有可能使用到的索引) | key (使用的索引) | key_len | ref   | rows | filtered | Extra |
+----+-------------+-------+------------+-------+---------------+------+---------+-------+------+----------+-------+
|  1 | SIMPLE      | t1    | NULL       | const |     xing,xm                           | xing               | 7       | const |    1 |      100 | NULL  |
+----+-------------+-------+------------+-------+---------------+------+---------+-------+------+----------+-------+
mysql> explain select * from t1 where xing='姚闻' and ming='文文';
+----+-------------+-------+------------+-------+---------------+------+---------+-------+------+----------+-------+
| id | select_type | table | partitions | type  | possible_keys | key  | key_len | ref   | rows | filtered | Extra |
+----+-------------+-------+------------+-------+---------------+------+---------+-------+------+----------+-------+
|  1 | SIMPLE      | t1    | NULL       | const | xing,ming,xm  | xing | 7       | const |    1 |      100 | NULL  |
+----+-------------+-------+------------+-------+---------------+------+---------+-------+------+----------+-------+

//冗余索引,某个列上有多个索引,比如建立了xm(xing,ming)联合索引又建立了ming(ming)索引,那么查询xing ming时xm索引发挥作用,查询xing时xm索引发挥作用,查询ming时ming索引发挥作用。ming这列就有2个索引。

show index from t1;//查看索引
+-------+------------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+---------------+
| t1    |          0 | ming     |            1 | ming        | A         |           4 | NULL     | NULL   | YES  | BTREE      |         |               |
| t1    |          1 | xm       |            1 | xing        | A         |           4 | NULL     | NULL   | YES  | BTREE      |         |               |
| t1    |          1 | xm       |            2 | ming        | A         |           4 | NULL     | NULL   | YES  | BTREE      |         |               |
+-------+------------+------+
mysql> show create table t1;
+-------+----------------------------------+
|Table    |    CreateTable  |
+-------+----------------------------------+
| t1    | CREATE TABLE `t1` (
  `xing` char(2) DEFAULT NULL,
  `ming` char(10) DEFAULT NULL,
  `zzz` char(20) NOT NULL DEFAULT '',
  UNIQUE KEY `ming` (`ming`),
  KEY `xm` (`xing`,`ming`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+--------------------------------+

mysql> alter table t1 drop index ming;//删除索引,
mysql> alter table t1 add primary key(xing);//增加主键索引,
mysql> alter table t1 drop primary key;//删除主键索引,

-----------------------------------------------------------------------------------------------
函数: 列可以当成变量,可以运算。
mysql> select 3*3;
+-----+
| 3*3 |
+-----+
|   9 |
+-----+
mysql> select floor(shop_price) from goods;//取整
mysql> select rand()*5+5,floor(shop_price) from goods limit 3;
+-------------------+-------------------+
| rand()*5+5        | floor(shop_price) |
+-------------------+-------------------+
| 7.222229537761052 |              1388 |
| 6.174204159690257 |                58 |
| 9.204332338836354 |                68 |
+-------------------+-------------------+
mysql> select left(goods_name,3) from goods limit 3;//左边截3个
+--------------------+
| left(goods_name,3) |
+--------------------+
| kd8                |
| ggg                |
| htc                |
+--------------------+
mysql> select right(goods_name,3) from goods limit 3;//右边截3个
+---------------------+
| right(goods_name,3) |
+---------------------+
| 876                 |
| ttt                 |
| 0耳机               |
+---------------------+
mysql> select concat(goods_name,shop_price) from goods limit 3;
+-------------------------------+
| concat(goods_name,shop_price) |
+-------------------------------+
| kd8761388.00                  |
| gggggttttttt58.00             |
| htc原装5800耳机68.00          |
+-------------------------------+
mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2017-12-27 16:19:31 |
+---------------------+

--------------------------------------------------------------------------------------------------

事务:
start transaction;
update temp set num=num+100 where id='a';
update temp set num=num-100 where id='b';
commit;

start transaction;
update temp set num=num+100 where id='a';
rollback;

事务提交了是改不了的。
复制代码
复制代码
create table goods (
  goods_id mediumint(8) unsigned primary key auto_increment,
  goods_name varchar(120) not null default '',
  cat_id smallint(5) unsigned not null default '0',
  brand_id smallint(5) unsigned not null default '0',
  goods_sn char(15) not null default '',
  goods_number smallint(5) unsigned not null default '0',
  shop_price decimal(10,2) unsigned not null default '0.00',
  market_price decimal(10,2) unsigned not null default '0.00',
  click_count int(10) unsigned not null default '0'
) engine=myisam default charset=utf8;

insert into `goods` values (1,'kd876',4,8,'ecs000000',1,1388.00,1665.60,9),
(4,'诺基亚n85原装充电器',8,1,'ecs000004',17,58.00,69.60,0),
(3,'诺基亚原装5800耳机',8,1,'ecs000002',24,68.00,81.60,3),
(5,'索爱原装m2卡读卡器',11,7,'ecs000005',8,20.00,24.00,3),
(6,'胜创kingmax内存卡',11,0,'ecs000006',15,42.00,50.40,0),
(7,'诺基亚n85原装立体声耳机hs-82',8,1,'ecs000007',20,100.00,120.00,0),
(8,'飞利浦9@9v',3,4,'ecs000008',1,399.00,478.79,10),
(9,'诺基亚e66',3,1,'ecs000009',4,2298.00,2757.60,20),
(10,'索爱c702c',3,7,'ecs000010',7,1328.00,1593.60,11),
(11,'索爱c702c',3,7,'ecs000011',1,1300.00,0.00,0),
(12,'摩托罗拉a810',3,2,'ecs000012',8,983.00,1179.60,13),
(13,'诺基亚5320 xpressmusic',3,1,'ecs000013',8,1311.00,1573.20,13),
(14,'诺基亚5800xm',4,1,'ecs000014',1,2625.00,3150.00,6),
(15,'摩托罗拉a810',3,2,'ecs000015',3,788.00,945.60,8),
(16,'恒基伟业g101',2,11,'ecs000016',0,823.33,988.00,3),
(17,'夏新n7',3,5,'ecs000017',1,2300.00,2760.00,2),
(18,'夏新t5',4,5,'ecs000018',1,2878.00,3453.60,0),
(19,'三星sgh-f258',3,6,'ecs000019',12,858.00,1029.60,7),
(20,'三星bc01',3,6,'ecs000020',12,280.00,336.00,14),
(21,'金立 a30',3,10,'ecs000021',40,2000.00,2400.00,4),
(22,'多普达touch hd',3,3,'ecs000022',1,5999.00,7198.80,16),
(23,'诺基亚n96',5,1,'ecs000023',8,3700.00,4440.00,17),
(24,'p806',3,9,'ecs000024',100,2000.00,2400.00,35),
(25,'小灵通/固话50元充值卡',13,0,'ecs000025',2,48.00,57.59,0),
(26,'小灵通/固话20元充值卡',13,0,'ecs000026',2,19.00,22.80,0),
(27,'联通100元充值卡',15,0,'ecs000027',2,95.00,100.00,0),
(28,'联通50元充值卡',15,0,'ecs000028',0,45.00,50.00,0),
(29,'移动100元充值卡',14,0,'ecs000029',0,90.00,0.00,0),
(30,'移动20元充值卡',14,0,'ecs000030',9,18.00,21.00,1),
(31,'摩托罗拉e8 ',3,2,'ecs000031',1,1337.00,1604.39,5),
(32,'诺基亚n85',3,1,'ecs000032',4,3010.00,3612.00,9);


 create table category (
 cat_id smallint unsigned auto_increment primary key,
 cat_name varchar(90) not null default '',
 parent_id smallint unsigned
 )engine myisam charset utf8;


INSERT INTO `category` VALUES 
(1,'手机类型',0),
(2,'CDMA手机',1),
(3,'GSM手机',1),
(4,'3G手机',1),
(5,'双模手机',1),
(6,'手机配件',0),
(7,'充电器',6),
(8,'耳机',6),
(9,'电池',6),
(11,'读卡器和内存卡',6),
(12,'充值卡',0),
(13,'小灵通/固话充值卡',12),
(14,'移动手机充值卡',12),
(15,'联通手机充值卡',12);


CREATE TABLE `result` (
  `name` varchar(20) DEFAULT NULL,
  `subject` varchar(20) DEFAULT NULL,
  `score` tinyint(4) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;



insert into result
values
('张三','数学',90),
('张三','语文',50),
('张三','地理',40),
('李四','语文',55),
('李四','政治',45),
('王五','政治',30);


create table a (
id char(1),
num int
)engine myisam charset utf8;

insert into a values ('a',5),('b',10),('c',15),('d',10);

create table b (
id char(1),
num int
)engine myisam charset utf8;

insert into b values ('b',5),('c',15),('d',20),('e',99);



 create table m(
     mid int,
     hid int,
     gid int,
     mres varchar(10),
     matime date
)engine myisam charset utf8;

create table t (
     tid int,
     tname varchar(20)
)engine myisam charset utf8;
 
 
 insert into m
     values
     (1,1,2,'2:0','2006-05-21'),
     (2,2,3,'1:2','2006-06-21'),
     (3,3,1,'2:5','2006-06-25'),
     (4,2,1,'3:2','2006-07-21');

 
 insert into t
     values
     (1,'国安'),
     (2,'申花'),
     (3,'布尔联队');



create table mian ( num int) engine myisam;
insert into mian values 
(3),
(12),
(15),
(25),
(23),
(29),
(34),
(37),
(32);


create table user (
uid int primary key auto_increment,
name varchar(20) not null default '',
age smallint unsigned not null default 0
) engine myisam charset utf8;



 create table boy (
    hid char(1),
     bname varchar(20)
 )engine myisam charset utf8;

 
 insert into boy (bname,hid)
     values
     ('屌丝','A'),
     ('杨过','B'),
     ('陈冠希','C');

 
 create table girl (
    hid char(1),
     gname varchar(20)
     )engine myisam charset utf8;

 
 insert into girl(gname,hid)
     values
     ('小龙女','B'),
     ('张柏芝','C'),
     ('死宅女','D');
复制代码

 

复制代码
1:mysql的函数肯定是要影响查询速度.
应该在建表时,通过合理的表结构减少函数的使用.
比如 email ,按@ 前后拆分.

2:如果确实要用函数,
比如 时间的格式化
在mysql里用date_format,在php里用date可以实现
优先放在业务逻辑层,即php层处理.

3:在查询时使用了函数,最大的一个坏处,
以 date_format(A)为例
则A列的索引将无法使用.

如果你针对某列作操作,而此次查询,又使用的此列的索引.
此时,速度将显著变慢.

例: 
sname, email 两列
email加了索引

Select name,email from table where right(email,6)='qq.com';
将会导致此次查询中, email的索引并不会产生效果.
复制代码

 


本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/p/8126884.html,如需转载请自行联系原作者

相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
打赏
0
0
0
0
49
分享
相关文章
MySQL底层概述—9.ACID与事务
本文介绍了数据库事务的ACID特性(原子性、一致性、隔离性、持久性),以及事务控制的演进过程,包括排队、排它锁、读写锁和MVCC(多版本并发控制)。文章详细解释了每个特性的含义及其在MySQL中的实现方式,并探讨了事务隔离级别的类型及其实现机制。重点内容包括:ACID特性(原子性、持久性、隔离性和一致性的定义及其实现方式)、事务控制演进(从简单的全局排队到复杂的MVCC,逐步提升并发性能)、MVCC机制(通过undo log多版本链和Read View实现高效并发控制)、事务隔离级别(析了四种隔离级别(读未提交、读已提交、可重复读、可串行化)的特点及适用场景)、隔离级别与锁的关系。
MySQL索引学习笔记
本文深入探讨了MySQL数据库中慢查询分析的关键概念和技术手段。
310 80
详解MySQL字符集和Collation
MySQL支持了很多Charset与Collation,并且允许用户在连接、Server、库、表、列、字面量多个层次上进行精细化配置,这有时会让用户眼花缭乱。本文对相关概念、语法、系统变量、影响范围都进行了详细介绍,并且列举了有可能让字符串发生字符集转换的情况,以及来自不同字符集的字符串进行比较等操作时遵循的规则。对于最常用的基于Unicode的字符集,本文介绍了Unicode标准与MySQL中各个字符集的关系,尤其详细介绍了当前版本(8.0.34)默认字符集utf8mb4。
621 81
MySQL底层概述—8.JOIN排序索引优化
本文主要介绍了MySQL中几种关键的优化技术和概念,包括Join算法原理、IN和EXISTS函数的使用场景、索引排序与额外排序(Using filesort)的区别及优化方法、以及单表和多表查询的索引优化策略。
MySQL底层概述—8.JOIN排序索引优化
MySQL原理简介—9.MySQL索引原理
本文详细介绍了MySQL索引的设计与使用原则,涵盖磁盘数据页的存储结构、页分裂机制、主键索引设计及查询过程、聚簇索引和二级索引的原理、B+树索引的维护、联合索引的使用规则、SQL排序和分组时如何利用索引、回表查询对性能的影响以及索引覆盖的概念。此外还讨论了索引设计的案例,包括如何处理where筛选和order by排序之间的冲突、低基数字段的处理方式、范围查询字段的位置安排,以及通过辅助索引来优化特定查询场景。总结了设计索引的原则,如尽量包含where、order by、group by中的字段,选择离散度高的字段作为索引,限制索引数量,并针对频繁查询的低基数字段进行特殊处理等。
MySQL原理简介—9.MySQL索引原理
MySQL底层概述—6.索引原理
本文详细回顾了:索引原理、二叉查找树、平衡二叉树(AVL树)、红黑树、B-Tree、B+Tree、Hash索引、聚簇索引与非聚簇索引。
MySQL底层概述—6.索引原理
MySQL秘籍之索引与查询优化实战指南
最左前缀原则。不冗余原则。最大选择性原则。所谓前缀索引,说白了就是对文本的前几个字符建立索引(具体是几个字符在建立索引时去指定),比如以产品名称的前 10 位来建索引,这样建立起来的索引更小,查询效率更快!
129 22
 MySQL秘籍之索引与查询优化实战指南
Mysql-常用函数及其用法总结
以上列举了MySQL中一些常用的函数及其用法。这些函数在日常的数据库操作中非常实用,能够简化数据查询和处理过程,提高开发效率。掌握这些函数的使用方法,可以更高效地处理和分析数据。
98 19
浅入浅出——MySQL索引
本文介绍了数据库索引的概念和各种索引结构,如哈希表、B+树、InnoDB引擎的索引运作原理等。还分享了覆盖索引、联合索引、最左前缀原则等优化技巧,以及如何避免索引误用,提高数据库性能。
MySQL进阶突击系列(05)突击MVCC核心原理 | 左右护法ReadView视图和undoLog版本链强强联合
2024年小结:感谢阿里云开发者社区每月的分享交流活动,支持持续学习和进步。过去五个月投稿29篇,其中17篇获高分认可。本文详细介绍了MySQL InnoDB存储引擎的MVCC机制,包括数据版本链、readView视图及解决脏读、不可重复读、幻读问题的demo演示。