Ale*_*ver 3 database postgresql
我无法date在PostgreSQL 9.6表中插入.
这是INSERT查询:
INSERT INTO rates (idproperty, from, to, price)
VALUES (1, '2017-03-14', '2017-04-30', 130);
Run Code Online (Sandbox Code Playgroud)
这就是结果:
ERROR: syntax error at or near "from"
LINE 1: INSERT INTO rates (idproperty, from, to, price)
Run Code Online (Sandbox Code Playgroud)
列from和to使用数据类型定义date.
谢谢
我相信你已经使用了postgresql保留字 - from并to创建了你的表.要在查询中使用它们,需要将它们括在引号中"
试试这种方式:
INSERT INTO rates (idproperty, "from", "to", price)
VALUES (1, '2017-03-14', '2017-04-30', 130);
Run Code Online (Sandbox Code Playgroud)
from并且to是PostgreSQL中的保留字。您需要使用以下命令将其转义":
-- This fails:
test=# SELECT from FROM rates;
ERROR: syntax error at or near "FROM"
LINE 1: SELECT from FROM rates;
^
-- This works:
test=# SELECT "from" FROM rates;
from
------
(0 rows)
Run Code Online (Sandbox Code Playgroud)
请参阅保留字列表:https : //www.postgresql.org/docs/current/static/sql-keywords-appendix.html
| 归档时间: |
|
| 查看次数: |
24487 次 |
| 最近记录: |