search
HomeDatabaseMysql TutorialIntroduction to skills commonly used in Mysql

This article brings you an introduction to the skills commonly used in Mysql. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

1. DML, DDL, DCL

1).DML(Dada Manipulation Language) 数据操纵语言(CRUD)
    A).新增
        a).单行插入 insert into A(a,b,c)values(a,b,c);
        b).多行插入 insert into A(a,b,c)values(a1,b1,c1),(a2,b2,c2);
    B).更新 
        a).set单字段 update A set a = 1 where c = 3;
        b).set多字段 update A set a = 1 ,b = 2 where c = 2;
    C).查询
        a).注意where条件 select a,b,c from A;
    D).删除
        a).注意where条件 delete from A where c = 3;
2).DDL(Dada Definition Language) 数据库定义语言
    A).CREATE
        a).创建表
            create table A(
                 a int(10),
                 b tinyint(4),
                 c tinyint(4),
                 d char(10),
                 ...
            );
    B).ALERT 
        a).新增字段 alter table A add tag int;
        b).修改字段 alter table A modify COLUMN tag char(20);
        c).删除字段 alter table A drop COLUMN tag;
    C).DROP
        a).删除表 drop table A;
        b).删除库 drop database Demo;
 3).DCL(Dada Control Language) 数据库控制语言
     A).grant 授权
         a).grant 权限 on 数据库对象 to 用户 
     B).deny 拒绝授权
         DENY 权限 TO 用户 
     C).revoke 撤销授权
         a).revoke 权限 on 数据库对象 from 用户 
 4).其他
     A).查看表结构
         a).desc A; 
         b).describe A; 
         c).show columns from A; 
     B).清空表数据
         a).truncate table A;

2. SQL statement analysis

 1).EXPLAIN、DESC语句---关键信息解释
     A).Type(system > const > eq_ref > ref > fulltext > ref_or_null > index_merge > unique_subquery > index_subquery > range > index > ALL)
     B).Possible_keys(NULL,则没有相关的索引。在这种情况下,可以通过检查WHERE子句看是否它引用某些列或适合索引的列来提高你的查询性能)
     C).Key(MySQL实际决定使用的键(索引))
     D).Key_len(索引中使用的字节数,不损失精确性的情况下,长度越短越好)
     E).Ref(连接匹配条件,即哪些列或常量被用于查找索引列上的值)
     F).Rows(MySQL根据表统计信息及索引选用情况,估算的找到所需的记录所需要读取的行数)
     G).Extra(MySQL解决查询的详细信息)
 2).SHOW PROCESSLIST 分析

3. Mysql executes the stored procedure through job task scheduling (event)

1).事件(EVENT) 调用 函数(f(x))(存储过程)
    a).事件 
        Call proc_detail();
    b).存储过程 
        CREATE PROCEDURE proc_detail()
        BEGIN
            DECLARE  id1  bigint(20);
            DECLARE  openid1  varchar(100); 
             DECLARE  unionid1  varchar(100); 
            -- 遍历数据结束标志
            DECLARE done INT DEFAULT FALSE;
            -- 游标
            DECLARE cur_account CURSOR FOR select id,openid,unionid from m_users where phone_bind =1 ;
            -- 将结束标志绑定到游标
            DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
            -- 打开游标
            OPEN  cur_account;     
            -- 遍历
            read_loop: LOOP
                    -- 取值 取多个字段
                    FETCH  NEXT from cur_account INTO id1,openid1,unionid1;
                    IF done THEN
                        LEAVE read_loop;
                     END IF;
         
                -- 你自己想做的操作
                            insert into m_users_details(uid,openid,unionid,style) VALUES(id1,openid1,unionid1,1); 
            END LOOP;
            CLOSE cur_account;
        END


The above is the detailed content of Introduction to skills commonly used in Mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete
图文详解mysql架构原理图文详解mysql架构原理May 17, 2022 pm 05:54 PM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

mysql的msi与zip版本有什么区别mysql的msi与zip版本有什么区别May 16, 2022 pm 04:33 PM

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

mysql怎么去掉第一个字符mysql怎么去掉第一个字符May 19, 2022 am 10:21 AM

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

mysql怎么替换换行符mysql怎么替换换行符Apr 18, 2022 pm 03:14 PM

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

mysql怎么将varchar转换为int类型mysql怎么将varchar转换为int类型May 12, 2022 pm 04:51 PM

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

MySQL复制技术之异步复制和半同步复制MySQL复制技术之异步复制和半同步复制Apr 25, 2022 pm 07:21 PM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

mysql怎么判断是否是数字类型mysql怎么判断是否是数字类型May 16, 2022 am 10:09 AM

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。

带你把MySQL索引吃透了带你把MySQL索引吃透了Apr 22, 2022 am 11:48 AM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),