有時候我們給表或者字段命名時,會無意中選擇了一個SQL中的關鍵字進行命名,然后就報錯了:
ERROR: syntax error at or near "limit"
MySQL解決方法:
在MySQL中需要添加 ``
create table `order` (id int, `limit` int); # 由於order和limit都是MySQL中的關鍵字,必須加上``才能使用
PostgreSQL解決方法:
在PostgreSQL中需要添加 ""
create table "order" (id int, "limit" int); # 由於order和limit都是PostgreSQL中的關鍵字,必須加上""才能使用