MySQL cannot write data to the keyword conflict

Source: Internet
Author: User

problem Description: A new table was created today using MySQL. A syntax error was reported when inserting data. Because you are using the Mabits Code Auto-generation tool, and you do not overwrite the SQL statement. So be sure that the SQL statement part should not be written incorrectly. So immediately realize that there is a problem with the field in the possible table. Then look at the fields inside the table and find that there is a DESC field that conflicts with the descending keyword in mysql. The field is then rewritten as a describe. Here, I think the problem should be solved. To think, and conflict again. Describe is also a key word for MySQL. So I searched the MySQL keyword list on the Internet.

The following is the MySQL keyword table

  

MySQL 5.5 Reserved Keywords

ACCESSIBLE 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 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 DIV
DOUBLE DROP DUAL
EACH ELSE ELSEIF
ENCLOSED ESCAPED EXISTS
EXIT EXPLAIN FALSE
FETCH FLOAT FLOAT4
FLOAT8 FOR FORCE
FOREIGN FROM FULLTEXT
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 LEADING LEAVE
LEFT LIKE LIMIT
LINEAR LINES LOAD
LOCALTIME LOCALTIMESTAMP LOCK
LONG LONGBLOB LONGTEXT
LOOP LOW_PRIORITY MASTER_SSL_VERIFY_SERVER_CERT
MATCH MAXVALUE 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 RANGE READ
READS READ_WRITE REAL
REFERENCES REGEXP RELEASE
RENAME REPEAT REPLACE
REQUIRE RESIGNAL RESTRICT
RETURN REVOKE RIGHT
RLIKE SCHEMA SCHEMAS
SECOND_MICROSECOND SELECT SENSITIVE
SEPARATOR SET SHOW
SIGNAL 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 XOR YEAR_MONTH
ZEROFILL

MySQL 5.5 added reserved keywords

GENERAL IGNORE_SERVER_IDS MASTER_HEARTBEAT_PERIOD
MAXVALUE RESIGNAL SIGNAL
SLOW

MySQL allows some of the keywords you use to use the English ' number, such as:

    • ACTION
    • BIT
    • DATE
    • ENUM
    • NO
    • TEXT
    • TIME
    • TIMESTAMP

The keywords in the above table should be designed to avoid these unnecessary conflicts when designing the database.

Problem solving: replace keywords with non-keywords.

Experience Summary: when the database is manipulated by the program, MySQL parses the SQL statements in your code, and if the fields of the operation contain keywords, the SQL statements you write can be interpreted incorrectly, and the SQL statements are wrong. The type of database is still relatively large. There are some keywords, each version is slightly different. When designing a database table, you should design a special field name, as long as possible, to avoid conflicts with keywords.

MySQL cannot write data to the keyword conflict

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.