mysql
kong-kong
记录流水账
展开
-
mysql字段脚本
mysql字段脚本原创 2023-07-14 17:23:51 · 239 阅读 · 0 评论 -
mysql实现序列1
【代码】mysql实现序列1。原创 2023-06-26 17:55:10 · 336 阅读 · 0 评论 -
ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA
创建function的时候,报这个错误。原创 2023-06-26 17:46:41 · 235 阅读 · 0 评论 -
mysql存储过程
mysql原创 2022-06-28 16:47:16 · 327 阅读 · 0 评论 -
Buffer Pool
Buffer PoolThe buffer pool is an area in main memory where InnoDB caches table and index data as it is accessed. The buffer pool permits frequently used data to be accessed directly from memory, which speeds up processing. On dedicated servers, up to 80%翻译 2022-03-13 16:47:01 · 180 阅读 · 0 评论 -
Using index 和 Using index condition 区别
基础数据员工表CREATE TABLE `employees1` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(24) NOT NULL DEFAULT '' COMMENT '姓名', `firstname` varchar(24) NOT NULL DEFAULT '' COMMENT 'firstname', `lastname` varchar(24) NOT NULL DEFAULT '' COMMENT 'las原创 2022-02-24 19:31:08 · 1097 阅读 · 0 评论 -
Mysql-RR隔离级别-非唯一索引例子
脚本CREATE TABLE `account5` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `age` int(11) NULL DEFAULT NULL, `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL D原创 2021-12-09 19:23:27 · 627 阅读 · 0 评论 -
Mysql-RR隔离级别-主键范围锁定例子
前言每次session使用之前,都要设置非自动提交set session autocommit=0;查看日志命令SHOW ENGINE INNODB STATUS ;脚本CREATE TABLE `account3` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `age` int(11)原创 2021-12-08 19:18:02 · 762 阅读 · 0 评论 -
Mysql-RR隔离级别+存在的主键+唯一索引例子
前言每次session使用之前,都要设置非自动提交set session autocommit=0;查看日志命令SHOW ENGINE INNODB STATUS ;脚本CREATE TABLE `account3` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `age` int(11)原创 2021-12-08 19:14:00 · 515 阅读 · 0 评论 -
Mysql-RR隔离级别-不存在的主键例子
前言每次session使用之前,都要设置非自动提交set session autocommit=0;查看日志命令SHOW ENGINE INNODB STATUS ;脚本CREATE TABLE `account2` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `age` int(11)原创 2021-12-08 11:39:10 · 676 阅读 · 0 评论 -
Mysql-RR隔离级别-存在的主键例子
前言每次session使用之前,都要设置非自动提交set session autocommit=0;查看日志命令SHOW ENGINE INNODB STATUS ;脚本CREATE TABLE `account2` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `age` int(11)原创 2021-12-07 22:38:56 · 245 阅读 · 0 评论 -
二级索引,索引键一样情况下,有没有排序的,根据什么排序的?
表结构CREATE TABLE t1( id int NOT NULL AUTO_INCREMENT, number int DEFAULT NULL, PRIMARY KEY (id))ENGINE=InnoDB DEFAULT CHARSET=utf8;ALTER TABLE t1 ADD INDEX t1_number_index (`number`)初始化数据insert into t1(id,number) values(1,2);insert into t1(id原创 2021-08-12 19:18:47 · 680 阅读 · 1 评论 -
mysql主键生成规则(不指定主键情况下)
Each InnoDB table has a special index called the clustered index that stores row data. Typically, the clustered index is synonymous with the primary key. To get the best performance from queries, inserts, and other database operations, it is important to .翻译 2021-08-04 21:10:42 · 445 阅读 · 0 评论 -
docker安装mariadb
docker pull mariadb# 目录作为和容器的映射目录mkdir -p /data/mariadb/datadocker run --name mariadb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v /data/mariadb/data:/var/lib/mysql -d mariadb--name 启动容器设置容器名称为mariadb- p 设置容器的3306端口映射到主机3306端口-e M...原创 2021-06-08 22:53:18 · 402 阅读 · 1 评论 -
docker安装mysql主从
拉取mysql镜像docker pull mysql:5.7启动主节点对外端口3339docker run -p 3339:3306 --name mysql-master -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7启动从节点对外端口3340docker run -p 3340:3306 --name mysql-slave-1 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7查看正在运行的容器docker原创 2021-06-08 21:18:37 · 296 阅读 · 0 评论 -
mariadb特有函数
NVL文档路径MariaDB starting with 10.3From MariaDB 10.3, NVL is a synonym for IFNULL.原创 2021-06-03 09:04:25 · 379 阅读 · 0 评论 -
mysql command
crud统计数show status like 'com_select';show status like 'com_insert';show status like 'com_update';show status like 'com_delete';查看慢查询show variables like '%slow_query%';show variables like '%quer%';show global variables like '%long_query%';连接相关#原创 2021-06-02 21:07:26 · 221 阅读 · 0 评论 -
XA Transaction SQL Statements
https://dev.mysql.com/doc/refman/5.7/en/xa-statements.html语法xid: gtrid [, bqual [, formatID ]]gtrid: 全局事务idbqual: 局部事务idXA {START|BEGIN} xid [JOIN|RESUME]XA END xid [SUSPEND [FOR MIGRATE]]XA PREPARE xidXA COMMIT xid [ONE PHASE]XA ROLLBACK x原创 2021-06-01 21:57:33 · 287 阅读 · 0 评论 -
lower_case_table_names (mysql表名区分大小写)
However, this same statement is permitted on Windows. To avoid problems caused by such differences, it is best to adopt a consistent convention, such as always creating and referring to databases and tables using lowercase names. This convention is reco...翻译 2021-05-10 14:48:02 · 665 阅读 · 0 评论 -
py_innodb_page_info工具
安装python3yum install python3安装py_innodb_page_infogit clone https://github.com/lynnlz/py_innodb_page_info查看ibd文件信息python3 py_innodb_page_info.py /var/lib/mysql/test/account0.ibd详细信息python3 py_innodb_page_info.py -v /var/lib/mysql/test/account.ibd原创 2021-05-09 22:42:56 · 629 阅读 · 0 评论 -
22.2.1.6 Page Directory
The Page Directory part of a page has a variable number of record pointers. Sometimes the record pointers are called "slots" or "directory slots". Unlike other DBMSs,InnoDBdoes not have a slot for every record in the page. Instead it keeps a sparse dire...翻译 2021-03-20 22:21:02 · 368 阅读 · 0 评论 -
innodb的B+TREE层数
查看employee_1表desc employee_1总条数select count(*) from employee_1查看information_schema中相关表信息注意索引的PAGE_NO和:index_idSELECT b.name, a.name, index_id, type, a.space, a.PAGE_NO FROM information_schema.INNODB_SYS_INDEXES a, information_sche..原创 2021-03-18 18:11:53 · 369 阅读 · 0 评论 -
Block Nested-Loop and Batched Key Access Joins
8.2.1.11 Block Nested-Loop and Batched Key Access JoinsIn MySQL, a Batched Key Access (BKA) Join algorithm is available that uses both index access to the joined table and a join buffer. The BKA algorithm supports inner join, outer join, and semijoin ope翻译 2021-01-16 15:57:05 · 329 阅读 · 0 评论 -
Multi-Range Read Optimization
8.2.1.10 Multi-Range Read OptimizationReading rows using a range scan on a secondary index can result in many random disk accesses to the base table when the table is large and not stored in the storage engine’s cache. With the Disk-Sweep Multi-Range Rea翻译 2021-01-16 14:30:48 · 306 阅读 · 0 评论 -
Outer Join Optimization
Outer joins include LEFT JOIN and RIGHT JOIN.外部连接包括左连接和右连接。MySQL implements an A LEFT JOIN B join_specification as follows:MySQL实现了A LEFT JOIN B JOIN 规范,如下所示:Table B is set to depend on table A and all tables on which A depends.表B被设置为依赖于表A和A所依赖的所有表.翻译 2021-01-14 12:35:55 · 283 阅读 · 0 评论 -
Nested-Loop Join Algorithms
8.2.1.6 Nested-Loop Join AlgorithmsMySQL executes joins between tables using a nested-loop algorithm or variations on it.MySQL使用嵌套循环算法或其变体在表之间执行连接。Nested-Loop Join Algorithm 嵌套循环连接算法A simple nested-loop join (NLJ) algorithm reads rows from the first翻译 2021-01-11 23:17:25 · 323 阅读 · 0 评论 -
Mysql EXPLAIN 之 key_len
修改编码# 数据库alter database employees character set latin1;alter database employees character set utf8;alter database employees character set utf8mb4;# 表alter table employees character set latin1;alter table employees character set utf8;alter table em原创 2020-12-21 22:01:24 · 321 阅读 · 0 评论 -
Index Condition Pushdown Optimization
https://dev.mysql.com/doc/refman/5.7/en/index-condition-pushdown-optimization.html8.2.1.5Index Condition Pushdown OptimizationIndex Condition Pushdown (ICP) is an optimization for the case where MySQL retrieves rows from a table using an index. Witho.翻译 2020-12-14 18:35:08 · 381 阅读 · 0 评论 -
Engine Condition Pushdown Optimization
8.2.1.4Engine Condition Pushdown Optimization此优化只能由NDB存储引擎使用https://dev.mysql.com/doc/refman/5.7/en/engine-condition-pushdown-optimization.htmlThis optimization improves the efficiency of direct comparisons between a nonindexed column and a constan.翻译 2020-12-14 17:51:39 · 271 阅读 · 1 评论 -
SHOW Statements
13.7.5SHOW Statements13.7.5.1SHOW BINARY LOGS Statement列出服务器上的二进制日志文件SHOW BINARY LOGSSHOW MASTER LOGS13.7.5.2SHOW BINLOG EVENTS Statementhttps://dev.mysql.com/doc/refman/5.7/en/show-binlog-events.htmlSHOW BINLOG EVENTS [IN 'log_name'] [FR...翻译 2020-12-13 20:38:36 · 273 阅读 · 0 评论 -
ANALYZE TABLE
https://dev.mysql.com/doc/refman/5.7/en/analyze-table.htmlANALYZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE tbl_name [, tbl_name] ...ANALYZE TABLE performs a key distribution analysis and stores the distribution for the named table or tables. For MyISAM ta翻译 2020-12-13 19:53:03 · 3583 阅读 · 0 评论 -
OPTIMIZE TABLE
https://dev.mysql.com/doc/refman/5.7/en/optimize-table.html13.7.2.4 OPTIMIZE TABLE SyntaxOPTIMIZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE tbl_name [, tbl_name] ...OPTIMIZE TABLE reorganizes the physical storage of table data and associated index data,翻译 2020-12-12 11:16:51 · 1534 阅读 · 0 评论 -
CHECKSUM TABLE Statement
https://dev.mysql.com/doc/refman/5.7/en/checksum-table.html13.7.2.3CHECKSUM TABLE StatementCHECKSUM TABLE tbl_name [, tbl_name] ... [QUICK | EXTENDED]CHECKSUM TABLE reports a checksum for the contents of a table. You can use this statement to ver.翻译 2020-12-12 00:38:01 · 348 阅读 · 1 评论 -
Index Merge Optimization
8.2.1.3 Index Merge OptimizationThe Index Merge access method retrieves rows with multiple range scans and merges their results into one. This access method merges index scans from a single table only, not scans across multiple tables. The merge can .翻译 2020-12-09 22:45:21 · 313 阅读 · 0 评论 -
Range Optimization
The range access method uses a single index to retrieve a subset of table rows that are contained within one or several index value intervals. It can be used for a single-part or multiple-part index. The following sections describe conditions under which .翻译 2020-12-09 22:15:16 · 456 阅读 · 0 评论 -
WHERE Clause Optimization
8.2.1.1WHERE Clause OptimizationThis section discusses optimizations that can be made for processing WHERE clauses. The examples use SELECT statements, but the same optimizations apply for WHERE clauses in DELETE and UPDATE statements.本节讨论可以为处理...翻译 2020-12-09 18:31:00 · 301 阅读 · 0 评论 -
Optimizing SELECT Statements
Queries, in the form of SELECT statements, perform all the lookup operations in the database. Tuning these statements is a top priority, whether to achieve sub-second response times for dynamic web pages, or to chop hours off the time to generate huge ove.翻译 2020-12-08 18:56:21 · 260 阅读 · 0 评论 -
Comparison Functions and Operators
12.4.2Comparison Functions and OperatorsWhen an operator is used with operands of different types, type conversion occurs to make the operands compatible. Some conversions occur implicitly. For example, MySQL automatically converts strings to numbers a.翻译 2020-11-24 21:23:31 · 448 阅读 · 0 评论 -
String Data Types之SET
11.3.6The SET TypeA SET is a string object that can have zero or more values, each of which must be chosen from a list of permitted values specified when the table is created. SET column values that consist of multiple set members are specified with me.翻译 2020-11-24 20:26:58 · 447 阅读 · 0 评论 -
String Data Types之ENUM
11.3.5The ENUM TypeAn ENUM is a string object with a value chosen from a list of permitted values that are enumerated explicitly in the column specification at table creation time.ENUM是一个字符串对象,其值是从允许值的列表中选择的,这些值在表创建时在列规范中明确枚举。See Section 11.3....翻译 2020-11-23 23:29:59 · 443 阅读 · 0 评论