如何在postgres中插入money数据类型值

Ram*_*Ben 1 sql postgresql

嗨我是postgres的新手,在将数据插入货币类型字段时,我收到的错误为..这里我的示例表是

CREATE TABLE x_table
(
  t_name character varying(40) NOT NULL,
  currency money
)

INSERT INTO x_table(t_name, currency)
VALUES ('TEST', 1000);
Run Code Online (Sandbox Code Playgroud)

并收到错误消息 ERROR: column "currency" is of type money but expression is of type integer SQL state: 42804.

所以任何人都可以说如何解决这个问题..提前谢谢

Erw*_*ter 5

在现代版本中(使用9.1和9.3测试),上面的代码示例按原样工作.

在旧版本中,没有从integerto 定义的隐式强制转换money.
引用Postgres 9.1的发行说明:

添加对(int4和Joey Adams)铸造的支持int8money

此外,请务必考虑存储货币信息的替代方法:
PostgreSQL:哪种数据类型应该用于货币?