当前位置:网站首页>Whether there are keywords in MySQL
Whether there are keywords in MySQL
2022-06-21 20:07:00 【Yisu cloud】
mysql Is there a keyword in
This article mainly introduces “mysql Is there a keyword in ” Knowledge about , Xiaobian shows you the operation process through practical cases , The operation method is simple and fast , Practical , Hope this article “mysql Is there a keyword in ” The article can help you solve problems .
mysql There are keywords in .mysql A variety of keywords are provided in :1、BETWEEN, Use in WHERE Query the range of time or number after the statement ;2、CALL, For calling stored procedures ;3、CURRENT_DATE, Get date of day ;4、CURRENT_TIME, Get the current time ;5、CURRENT_USER, return MYSQL Username ;6、CURSOR, For declaration mysql Cursor in ;7、DISTINCT, For de duplication .
The operating environment of this tutorial :windows7 System 、mysql8 edition 、Dell G3 The computer .
In the use of MySQL When , Generally try to avoid using keywords as table names , For example, use keywords as table names , It needs to be written in a standard way SQL Statement plus []( or “) Distinguish between field names and table names .
The following is a list MySQL All keywords , Hope to use MySQL Our friends provide some reference help .
| ADD | ALL | ALTER |
| ANALYZE | AND | AS |
| ASC | ASENSITIVE | BEFORE |
| BETWEEN | BIGINT | BINARY |
| BLOB | BOTH | BY |
| CALL | CASCADE | CASE |
| CHANGE | CHAR | CHARACTER |
| CHECK | COLLATE | COLUMN |
| CONDITION | CONNECTION | CONSTRAINT |
| CONTINUE | CONVERT | CREATE |
| CROSS | CURRENT_DATE | CURRENT_TIME |
| CURRENT_TIMESTAMP | CURRENT_USER | CURSOR |
| DATABASE | DATABASES | DAY_HOUR |
| DAY_MICROSECOND | DAY_MINUTE | DAY_SECOND |
| DEC | DECIMAL | DECLARE |
| DEFAULT | DELAYED | DELETE |
| DESC | DESCRIBE | DETERMINISTIC |
| DISTINCT | DISTINCTROW | p |
| DOUBLE | DROP | DUAL |
| EACH | ELSE | ELSEIF |
| ENCLOSED | ESCAPED | EXISTS |
| EXIT | EXPLAIN | FALSE |
| FETCH | FLOAT | FLOAT4 |
| FLOAT8 | FOR | FORCE |
| FOREIGN | FROM | FULLTEXT |
| GOTO | GRANT | GROUP |
| HAVING | HIGH_PRIORITY | HOUR_MICROSECOND |
| HOUR_MINUTE | HOUR_SECOND | IF |
| IGNORE | IN | INDEX |
| INFILE | INNER | INOUT |
| INSENSITIVE | INSERT | INT |
| INT1 | INT2 | INT3 |
| INT4 | INT8 | INTEGER |
| INTERVAL | INTO | IS |
| ITERATE | JOIN | KEY |
| KEYS | KILL | LABEL |
| LEADING | LEAVE | LEFT |
| LIKE | LIMIT | LINEAR |
| LINES | LOAD | LOCALTIME |
| LOCALTIMESTAMP | LOCK | LONG |
| LONGBLOB | LONGTEXT | LOOP |
| LOW_PRIORITY | MATCH | MEDIUMBLOB |
| MEDIUMINT | MEDIUMTEXT | MIDDLEINT |
| MINUTE_MICROSECOND | MINUTE_SECOND | MOD |
| MODIFIES | NATURAL | NOT |
| NO_WRITE_TO_BINLOG | NULL | NUMERIC |
| ON | OPTIMIZE | OPTION |
| OPTIONALLY | OR | ORDER |
| OUT | OUTER | OUTFILE |
| PRECISION | PRIMARY | PROCEDURE |
| PURGE | RAID0 | RANGE |
| READ | READS | REAL |
| REFERENCES | REGEXP | RELEASE |
| RENAME | REPEAT | REPLACE |
| REQUIRE | RESTRICT | RETURN |
| REVOKE | RIGHT | RLIKE |
| SCHEMA | SCHEMAS | SECOND_MICROSECOND |
| SELECT | SENSITIVE | SEPARATOR |
| SET | SHOW | SMALLINT |
| SPATIAL | SPECIFIC | SQL |
| SQLEXCEPTION | SQLSTATE | SQLWARNING |
| SQL_BIG_RESULT | SQL_CALC_FOUND_ROWS | SQL_SMALL_RESULT |
| SSL | STARTING | STRAIGHT_JOIN |
| TABLE | TERMINATED | THEN |
| TINYBLOB | TINYINT | TINYTEXT |
| TO | TRAILING | TRIGGER |
| TRUE | UNDO | UNION |
| UNIQUE | UNLOCK | UNSIGNED |
| UPDATE | USAGE | USE |
| USING | UTC_DATE | UTC_TIME |
| UTC_TIMESTAMP | VALUES | VARBINARY |
| VARCHAR | VARCHARACTER | VARYING |
| WHEN | WHERE | WHILE |
| WITH | WRITE | X509 |
| XOR | YEAR_MONTH | ZEROFILL |
Here is a list of common mysql The role of keywords
| keyword | effect |
|---|---|
| ANALYZE | adopt Analyze Table The index statement can be repaired . Use “SHOW INDEX FROM Table name ” View the index status in the table , When the number of different values in the field is much more than that in the table CARDINALITY In quantity , The index basically doesn't work , Use this time “ANALYZE TABLE Table name ” The index can be repaired , Again using “SHOW INDEX FROM Table name ” You can see CARDINALITY Index returned to normal |
| BETWEEN | Use in WHERE Later time or number range query , Such as “SELECT * FROM USER WHERE CREATE BETWEEN '2020-11-20' AND '2020-11-30';” The query is 20 No. to 30 Data between numbers , If the time type is DATETIME The query range is 00:00:00, For example, in the above query statement, if CREATE_TIME by DATETIME type , The scope of the query is “2020-11-20 00:00:00 to 2020-11-30 00:00:00” |
| CALL | For calling stored procedures , Such as :CALL showUser() |
| CASCADE | Add after constraint , After setting, delete 、 When the master table is updated, the slave table will also be operated , for example :“ CONSTRAINT ' User information ' FOREIGN KEY (USER_NAME) REFERENCES TASK.USER (NAME) ON DELETE CASCADE ON UPDATE CASCADE”, After adding, when the user table changes the user name , The user name from the table will also be modified |
| CURRENT_DATE | Used to get the date of the day , Such as “SELECT CURRENT_DATE” Returns the date of the day |
| CURRENT_TIME | Used to get the current time , Such as "SELECT CURRENT_TIME" Returns the current hour, minute and second |
| DEFAULT CURRENT_TIMESTAMP | When creating a time field, if you add this code, it means that the current time is inserted by default when adding data , When creating a field :“ create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP” |
| ON UPDATE CURRENT_TIMESTAMP | If you add this code when creating a time field, it means that the current time will be synchronized by default when modifying data , When creating a field :“update_time timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP” |
| CURRENT_USER | return MYSQL Username |
| CURSOR | For declaration mysql Cursor in , Used in stored procedures , It acts as a pointer , usage :“DECLARE Cursor name CURSOR FRO The result set of the query ” |
| DECLARE | Used to declare variables in compound statements , For example, in a stored procedure , have access to SET Variable name = value Reassign in this way , The result in the example is 1 yes “ test ”, result 1(2) yes “ test 1” |
| DELAYED | Used to use deferred insert operations , In execution DELAYED When a statement is declared , The database will first return status information , Then put the insert operation into the queue , Wait for instructions that do not operate on the queue data to start executing the queue |
| DESCRIBE | Used to view the detailed design of fields in the data table , There are two uses :1.DESCRIBE Table name View all fields .2.DESCRIBE Table name Field name Used to view fields individually |
| DISTINCT | Remove duplicate data , Only de duplicated data can be returned , Must be in the first field of the query , It is often used to query how many pieces of data in a field are not repeated . Such as SELECT COUNT(DISTINCT name) FROM user |
| DISTINCTROW | De duplication for join table query , You can query the attached table data associated with the main table instead of the data not related to the queried main table , Such as SELECT DISTINCTROW user.id ,untitled.friend_name FROM user INNER JOIN untitled ON user.id = untitled.friend_id WHERE user.id = '1'; Users can be queried id Associated with untitled The names of friends in the table , Do not include friends of users who have no query |
| DROP | It is mainly used to delete the structure , Such as deleting database :DROP DATABASE Database name , Delete table :DROP TABLE Table name , Delete field :ALTER TABLE Table name DROP Field name |
| DUAL | Virtual table in mysql5.1 The above version will have , It feels like ORACLE That's what works , Because in ORACLE Queries used in must have FROM Table name , And in the mysql No error will be reported if there is no table name in the , If in mysql in SELECT 1+1 No problem, but in ORACLE China will report an error , You need to use it at this time SELECT 1+1 FROM DUAL, official declaration :DUAL It's entirely for the convenience of those who require all SELECT Every statement should have FROM or other People who love you |
| EXISTS | Used in WHERE Post judgment operation , The return result is a Boolean value , The usage method is to substitute the existing row into the query to check , If one or more rows of data are returned in the internal query , Then output the data of this line , On the contrary, if there is no data in the internal query, the data of this line will not be output , Such as :SELECT * FROM user u WHERE EXISTS(SELECT * FROM untitled n WHERE n.friend_id=u.id) What's back is untitled In the table friend Fields can be associated with user In the table id Associated data , It can also be in EXISTS Keyword prefix NOT All that is returned is irrelevant data |
| EXPLAIN | Use to view a sql Implementation , Whether the index is added or whether the full table scan is done , Usage mode : stay SELECT with , Such as EXPLAIN SELECT * FROM user |
| FULLTEXT | Full-text index , Used to optimize query speed , You can add... When creating a table FULLTEXT( Field 1, Field 2), You can also add... After creating the table ALTER TABLE Table name ADD FULLTEXT INDEX Index name ( Field name ) It should be noted that adding an index is , The table engine should use MyISAM Otherwise, it will report a mistake The used table type doesn't support FULLTEXT indexes |
| GRANT | Used for user permission operations , You can grant or delete user permissions , There are many ways to operate, such as :CREATE USER 'testUser'@'host' IDENTIFIED BY '123456'; Used to create users ,show grants for 'testUser'@'host'; View user permissions and other operations |
| GROUP | For grouping operations ,GROUP BY Field name The fields to be queried after grouping must be in GROUP BY The error will be reported after adding , More classic usage, such as :SELECT friend_name , COUNT(friend_name) FROM untitled GROUP BY friend_name Query the number of data pieces of a certain type |
| HAVING | Used to filter data after aggregation , And WHERE The difference is that ,WHERE It is used to filter data before aggregation. Aggregation functions such as COUNT,SUM etc. ,HAVING It is filtered after aggregation. You can use the aggregation function , for example :SELECT friend_name , COUNT(friend_name) FROM untitled GROUP BY friend_name HAVING COUNT(friend_name) >1 The query is friend_name The number of data pieces greater than one |
| HIGH_PRIORITY | be used for SELECT and INSERT sentence , Declare this operation as a high priority operation , The database will perform such operations first , Such as :SELECT HIGH_PRIORITY * FROM user When there are multiple operations at the same time , This statement takes precedence |
| IGNORE | It is often used to ignore error data during batch insertion , Such as :INSERT IGNORE INTO user (id,name,age) values(6,'pangqi',25); If the primary key id If it already exists, no error will be reported , Instead, perform the next insertion operation |
| INNER | Used for internal connection query , Set up ON After the conditions are met, all the qualified data will be displayed , Connect to the left , The difference between right connections is :INNER No focus ,mysql Will find out all the data that meet the conditions , So be careful not to appear Cartesian product when using , In addition, due to INNER yes mysql Default connection mode , So you can omit INNER Keywords such as :SELECT * FROM user JOIN untitled ON user.id = untitled.friend_id |
| INTERVAL | Mainly used for time interval , Such as :SELECT * FROM USER where create_time < NOW()-INTERVAL 4 DAY The data returned is the data created four days ago , Can also be DAY Replace with hours , minute , Year, month, etc , It can also be used to compare data, such as :SELECT INTERVAL(6,1,2,3,4,7,8,9,10) Returns the 4, Because in comparison mysql Can be indexed as 0 To compare the next data , When the next data is larger than the index is 0 When the data is ,mysql The index of the previous data will be returned |
| IS | mysql Medium IS Keywords are only used in IS NULL or IS NOT NULL in Such as :SELECT * FROM USER where update_time IS NULL |
| JOIN | Used to connect two tables , The connection mode is generally internal connection INNER JOIN, The right connection RIGHT JOIN, Left connection LEFT JOIN |
| KEY | KEY It's the physical structure of the database , There are two levels of meaning and function :1: constraint ,2: Indexes , Such as the declaration of primary key PRIMARY KEY (id),, There will be unique constraints , The index will be automatically added again |
| KILL | Used to terminate mysql Thread in , have access to SHOW PROCESSLIST View the thread currently in progress , Use KILL Threads id Thread termination , There are two modifiers 1:CONNECTION The default modifier can terminate all connections with the thread id Related links ,2:QUERY Terminate the statement now executed , But the connection will not be terminated |
| LABEL | Statement tags |
| LEAVE | Leave Statement to exit the process control statement block of the specified label , Usually used in begin…end, as well as loop, repeat, while In the loop statement of , It's like... In programming break equally , Usage mode LEAVE Circular name ; |
| LEFT | LEFT() The function is a string function , It returns the left part of a string of a specified length . Such as :SELECT LEFT(name,3) FROM user |
| LIKE | For fuzzy search , Collocation % And _ The common use ,% Represents a query for one or more wildcards , and _ Represents a character , Such as :SELECT * FROM user WHERE name LIKE '%i' You can find all name China and Israel i Data at the end , take % Switch to _ after , The query condition becomes a query name China and Israel i Data that ends with only one character in front |
| LIMIT | Used for paging queries , Such as :SELECT * FROM user LIMIT 4,5 The first parameter is the starting number As the above example, it starts from 4 Bar data starts to return , The second parameter is offset, as shown in the above example. The parameter is 5 Then it means to return from 4 Back of bar 5 Data , The previous offset can be -1 Represents all data after the initial number of queries , But this writing is mysql Officially considered a mistake , So the newer version mysql It doesn't work , The best way is to give a larger number |
| LOCALTIME | Local time , It can be used as a query result field ,where Conditions , When inserting the current time , Update time, etc ,mysql There are many time functions , You can choose different functions to use according to your needs , example :SELECT LOCALTIME,NOW(),sysdate(), localtimestamp, localtimestamp(); |
| LOCK | Lock table and unlock MySQL Enables client sessions to explicitly acquire table locks , To access the table in collaboration with other sessions , Or prevent other sessions from modifying the table when the session needs mutually exclusive access . A session can only acquire or release locks for itself . One session cannot acquire the lock of another session , You can't release the lock that another conversation holds . example :LOCK table user read local A lock table operation will be generated , All operations to modify the table will be rejected and prompted :Table 'user' was locked with a READ lock and can't be updated, have access to unlock tables; Keyword unlock |
| LOW_PRIORITY | Low priority ,MySQL Allows you to change the priority of statement scheduling , It enables better collaboration of queries from multiple clients , In this way, a single client will not wait for a long time due to locking . Commonly used in DELETE、INSERT、LOAD DATA、REPLACE and UPDATE In the sentence , example :update LOW_PRIORITY user set username = 'zhangsan' under these circumstances , If the writer is waiting , The second reader arrived , Then allow the second reader to plug in before the writer . Only when there are no other readers , The writer is allowed to start the operation . |
| MOD | Take the cofunction , Such as :select mod(12,5) Returns the remainder 2 |
| NATURAL | Natural join , yes JOIN A kind of , It is characterized by automatic record matching of fields with the same name in the table , These fields with the same name can be of different types , Therefore, the types of fields in the table can be different , It can be applied to INNER ,LEFT etc. JOIN in , example :select * from user NATURAL LEFT JOIN user2 ad locum user And user2 The difference is except id outside user2 The field will be followed by 1, This will result in automatic use when connecting id Association , And so it turns out |
| OPTIMIZE | effect : Optimize the defragmentation and index of the table , When the database stores data, the database allocates table space , And index the data. When the data is deleted, the database will not recover these resources, but wait for new data to fill these gaps , Use OPTIMIZE Keywords can actively clear these occupied resources , usage :optimize table The name of the table |
| RANGE | Partition : Based on a given interval range , The value of this field in a given interval is required to be continuous , When the operation is performed, the corresponding partition will be taken , Can greatly improve efficiency , The requirement is that if the table has a primary key, the partition field should also be in the row and column of the primary key , usage : Create table statement +PARTITION BY RANGE (xuehao) (PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11),PARTITION p2 VALUES LESS THAN (16), PARTITION p3 VALUES LESS THAN (21)); |
| REFERENCES | Establish foreign key relationship , In the statement of creating a table :FOREIGN KEY(uid) REFERENCES users(id) It means the field uid Will and user The primary key field of the table id Connect |
| REGEXP | Regular expressions , You can use regular expressions in conditions , Use SELECT * FROM user WHERE email NOT REGEXP'^[A-Z0-9._%-][email protected][A-Z0-9.-]+.[A-Z]{2,4}$' |
| RENAME | Modify table name , Use :rename table user2 to user3; |
| REPEAT | Copy the given data as a string for a specified number of times, such as :select REPEAT(3,3) The result is “333” |
| REPLACE | Replace all specified strings , Such as :select REPLACE(' This is a string , Or a character ',' One ',' Two '); |
| REVOKE | Revocation has been given to MySQL User permissions , Such as :revoke all on *.* from [email protected]; Remember to refresh the user permission table after completion FLUSH PRIVILEGES; |
| RIGHT | Truncate the string , Such as :select RIGHT(' This is a string ',5), The string of specified digits will be intercepted in reverse order |
| RLIKE | Fuzzy query , And like When it's different ,rlike The content of can be regular , And may not exactly match , Such as :select * from user where email RLIKE '^www.*$'; |
| SEPARATOR | The query result can be changed into one line by string connection ,SEPARATOR Specify connector , Need to cooperate GROUP BY Use , Such as :SELECT *, GROUP_CONCAT(username order by username separator ';') SCORE FROM user GROUP BY email RLIKE '^www.*$' |
| USING | When connecting queries, if the field names are the same, they can be used as connection conditions ,using Can replace on Appear as :select * from user left join students USING(quanxian) |
| WHILE | Circular statement keyword , Used in stored procedures , It needs to be used in combination with process control statements , Such as :CREATE PROCEDURE fun() BEGIN SET @sum:=10; WHILE @sum > 0 DO SELECT @sum; SET @sum:[email protected]; END WHILE; END CALL fun(); DROP PROCEDURE fun |
| XOR | Express logical XOR , When any one of the operands is NULL when , The return value is NULL, For non NULL The number of operations , If two logical true and false values are different , Then the returned result is 1, Otherwise 0, Such as :select true XOR null;select true XOR true;select true XOR false; |
| ZEROFILL | When creating a table, add this keyword to the numeric type , If the number of inserted digits is insufficient, the corresponding number of digits will be filled automatically , Such as :CREATE TABLE student3 ( id int(11) unsigned zerofill not null, xuehao int(50) NOT NULL );insert into student3 value(1,2); select * from student3; |
About “mysql Is there a keyword in ” That's all for , Thanks for reading . If you want to know more about the industry , You can pay attention to the Yisu cloud industry information channel , Xiaobian will update different knowledge points for you every day .
边栏推荐
- [high frequency interview questions] difficulty 1/5, popular enumeration simulation questions
- HMS Core机器学习服务身份证识别功能,实现信息高效录入
- Medical expense list can be entered at a second speed, and OCR recognition can help double the efficiency
- RecycleView拖动效果
- Source code analysis of ArrayList
- Cloudcompare & PCL calculates transformation matrix based on matching points
- 【ICML2022】CtrlFormer: 通过Transformer学习视觉控制的可迁移状态表示
- flink-connector-mysql-cdc-2.2.0,生成全量快照阶段,是按照Table
- 2022-06-20
- 范畴(Category)
猜你喜欢

一种简单的架构设计逻辑|得物技术
![婴儿名字[连通分量之邻接矩阵与DFS]](/img/60/83da6ce2fd2336fe1c4aead3260b77.png)
婴儿名字[连通分量之邻接矩阵与DFS]

汇编语言贪吃蛇、俄罗斯方块双任务设计实现详解(三)——俄罗斯方块详细设计

Kubernetes migration of persistent volumes across storageclasses Complete Guide

Flink 系例 之 TableAPI & SQL 与 示例模块

LeetCode个人题解(剑指offer 21-25)21. 调整数组顺序使奇数位于偶数前面,22. 链表中倒数第k个节点,24. 反转链表,25. 合并两个排序的链表

Grain College p40~43

新手使用APICloud可视化开发搭建商城主页

SQL语句知识点有哪些

Custom code template
随机推荐
How does the easycvr intelligent edge gateway hardware set power on self start?
新手使用APICloud可视化开发搭建商城主页
MySQL must know - Chapter 9 - Search with regular expressions
Startup mode of Jupiter notebook and related problems
mysql如何查询最大id值
[cvpr2022] CMU tutorial on multimodal machine learning, 200+ pages to explain the knowledge of multimodal learning system with six challenges of representation, alignment, reasoning, migration, genera
函子(Functor)
NSIS 运行bat的方法汇总
机器学习之线性模型与决策树
Kubernetes migration of persistent volumes across storageclasses Complete Guide
flink-connector-mysql-cdc-2.2.0,生成全量快照阶段,是按照Table
出院小结识别api接口-医疗票据OCR识别/出院诊断记录/电子病历/理赔服务
Introduction to machine learning
When the move protocol beta is in progress, the ecological core equity Momo is divided
API de table & SQL et module d'échantillon pour le système Flink
How to simulate a request or modify a requested domain name in Chrome browser
基于k近邻的MNIST图像分类对比
JVM内存结构
Jupyter Notebook启动方式及相关问题
mysql中有没有关键字