與此question類似,我有一個CSV匯率,其精度高達9位小數。用於在MySQL中存儲高精度小數的數據類型
例如:0.558659218
,4470.011076
,7.02E-05
,0.000641138
,20832.46989
我應該使用哪種數據類型的列?
我試圖FLOAT
,DOUBLE
和DECIMAL(11,11)
,它們產生的以下警告之一:
- 出於對列「列名」範圍值中的行X
- 值在行截斷爲列「列名」 X
當我使用SHOW WARNINGS
命令。
僅供參考,SQL語句如下(但我想這是不相關):
LOAD DATA LOCAL INFILE 'currency.csv' INTO TABLE the_currency FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (currency_code, currency_buyin, currency_buyout);
的CSV樣本數據如下:
PHP,41.46218559,0.024118362
PKR,95.71731228,0.010447431
PLN,3.2056255,0.311951599
PYG,4470.011076,0.000223713
QAR,3.641148462,0.274638623
RON,3.524472347,0.283730415
RSD,87.59544136,0.011416119
RUB,31.41607934,0.031830834
RWF,626.1686594,0.001597014
SAR,3.750383024,0.266639432
SBD,7.130814403,0.140236436
SCR,13.08102784,0.076446592
SDG,4.412494807,0.226629162
SEK,6.683528257,0.149621571
SGD,1.221878378,0.81841206
SHP,0.623503208,1.603840987
SLL,4349.905174,0.00022989
SOS,1615.486542,0.000619009
SPL,0.166666667,6
SRD,3.274628066,0.305378193
STD,18949.99968,5.28E-05
SVC,8.75,0.114285714
MySQL版本:5.5.34-0ubuntu0.12.04.1
和我正在使用控制檯命令。
似乎我誤解了(不仔細閱讀手冊)'DECIMAL(M,D)'的定義。謝謝! – Raptor