在MySQL中,有一些被稱為保留字和關鍵字的特殊單詞,在使用SQL命令進行操作時需要注意這些單詞的使用。
保留字是指被MySQL保留為特殊用途的單詞,不能用作表名、列名或其他標識符。以下是MySQL中常用的保留字:
ADD ALL ALTER AND AS ASC AVG BETWEEN BY CHAR COLUMN COUNT CREATE DATABASE DECIMAL DEFAULT DELETE DESC DISTINCT DROP ELSE END ESCAPE EXISTS FALSE FROM GROUP HAVING IN INDEX INNER INSERT INTO IS JOIN KEY LEFT LIKE LIMIT MAX MIN NOT NULL ON OR ORDER OUTER PRIMARY PROCEDURE REFER RIGHT SELECT SET TABLE TRUE UNION UNIQUE UPDATE VALUES WHERE
關鍵字是指在某個SQL命令中具有特定含義的單詞。以下是MySQL中常用的關鍵字:
SELECT FROM WHERE DISTINCT ORDER BY GROUP BY HAVING LIMIT AS INNER JOIN LEFT JOIN RIGHT JOIN OUTER JOIN FULL JOIN ON IS NULL LIKE IN BETWEEN CASE WHEN THEN ELSE END NOT AND OR XOR IN ANY ALL EXISTS NULLIF COALESCE CASE WHEN THEN ELSE END CAST SUM COUNT AVG MIN MAX YEAR MONTH DAY HOUR MINUTE SECOND
使用保留字和關鍵字作為標識符會導致語法錯誤,因此在創建表、定義列名等情況下,應當避免使用這些單詞。
上一篇mysql 保存小數
下一篇mysql 保存存儲過程