【问题标题】:sql money column [duplicate]sql钱列[重复]
【发布时间】:2012-09-21 09:55:25
【问题描述】:

可能重复:
storing money amounts in mysql

我正在尝试在我的 sql 数据库中创建一个表,该表有几个不同的 int 列、名称和其他一些东西。但是有两个表我想在其中存储货币值。不超过 3 位,两个显示时的小数位。

这是我写的sql

CREATE TABLE `5050goose` (
    `goose_id` int(11) unsigned NOT NULL auto_increment,
    `name` varchar(100) NOT NULL default '',  
    `width` int(8),
    `height` int(8),
    `normal_fill` int(8),
    `our_fill` int(8),
    `old_price` smallmoney(8),
    `price` smallmoney(8),
    PRIMARY KEY  (`goose_id`)
    ) TYPE=MyISAM;

但是当我执行这个时,我得到了这个错误

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'smallmoney(8),
    `price` smallmoney(8),
    PRIMARY KEY  (`goosedown_id`)
    ) TYPE' at line 8 

这清楚地表明 smallmoney 对我不起作用。所以我想知道如何在我的 sql 数据库中存储货币价值。

【问题讨论】:

标签: mysql sql


【解决方案1】:

确实你是对的,smallmoney 不是 mysql 中的数据类型。看看DECIMAL

http://dev.mysql.com/doc/refman/5.6/en/fixed-point-types.html

【讨论】:

  • 酷,已经使用 DECIMAL(6,2)。这显然应该涵盖 -999.99 和 + 999,99 之间的任何数字,为链接欢呼
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-19
  • 1970-01-01
  • 2013-03-15
  • 2015-10-02
  • 2014-03-13
相关资源
最近更新 更多