In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
No zuo no die series, from wiki of pg.
This section is about: don't use money.
The reason is:
Money
It's a fixed-point type, implemented as a machine int, so arithmetic with it is fast. But it doesn't handle fractions of a cent (or equivalents in other currencies), it's rounding behaviour is probably not what you want.
It doesn't store a currency with the value, rather assuming that all money columns contain the currency specified by the database's lc_monetary locale setting. If you change the lc_monetary setting for any reason, all money columns will contain the wrong value. That means that if you insert'$10.00' while lc_monetary is set to 'en_US.UTF-8' the value you retrieve may be' 10 Lei' or'¥1000' if lc_monetary is changed.
Storing a value as a numeric, possibly with the currency being used in an adjacent column, might be better.
The reason is that the money type is a fixed-point type, which is realized by the machine int type in the computer, and the rounding behavior may not meet the expectations, and the field does not store currency units, depending on the lc_monetary setting of the database, and this value may be problematic if the unit of measurement changes, so use numeric to store numerical values and use other fields to store currency units.
[local]: 5432 pg12@testdb=# drop table if exists tactile moneytellanNOTICE: table "t_money" does not exist, skippingDROP TABLETime: 35.404 ms [local]: 5432 pg12@testdb=# create table t_money (id int,c1 money); CREATE TABLETime: 133.600 ms [local]: 5432 pg12@testdb=# insert into t_money (id,c1) values (112343.01); INSERT 0 1Time: 0.929 ms [local]: 5432 pg12@testdb=# insert into t_money (id,c1) values (212343.31234) INSERT 0 1Time: 0.640 ms [local]: 5432 pg12@testdb=# insert into t_money (id,c1) values (3pg12@testdb=# insert into t_money 112343.50); INSERT 0 1Time: 0.599 ms [local]: 5432 pg12@testdb=# insert into t_money (id,c1) values (4Med 112343.99); INSERT 0 1Time: 0.523 ms [local]: 5432 pg12@testdb=# insert into t_money (id,c1) values (5mei 112343.3199) INSERT 0 1Time: 0.483 ms [local]: 5432 pg12@testdb=# insert into t_money (id,c1) values (6pg12@testdb=# insert into t_money 112343.3150); INSERT 0 1Time: 0.533 ms [local]: 5432 pg12@testdb=# insert into t_money (id,c1) values (7Med 112343.3101); INSERT 0 1Time: 0.531 ms [local]: 5432 pg12@testdb=#
Query data, the actual data is rounded, keeping two decimal places
[local]: 5432 pg12@testdb=# select * from tweets money.id | C1-+-1 | $112343.01 2 | $112343.31 3 | $112343.50 4 | $112343.99 5 | $112343.326 | $112343.327 | $112343.31 (7 rows) Time: 0.321 ms
Modify the currency setting of the database parameter to zh_CN
[local]: 5432 pg12@testdb=# [local]: 5432 pg12@testdb=# show lc_monetary; lc_monetary-zh_CN.UTF-8 (1 row) Time: 5.212 ms [local]: 5432 pg12@testdb=# select * from t_money Id | C1-+-1 | ¥112343.01 2 | ¥112343.31 3 | ¥112343.50 4 | ¥112343.99 5 | ¥112343.32 6 | ¥112343.32 7 | ¥112343.31 (7 rows) Time: 2.092 ms [local]: 5432 pg12@testdb=#
The dollar bill has become RMB.
references
Don't Do This
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Select to_date ('2005-12-25 Person13-25-5-5-5-5) from dual
© 2024 shulou.com SLNews company. All rights reserved.