Jump to content
  • 0

какой тип данных выбрать для денег ?


asker2
 Share

Question

14 answers to this question

Recommended Posts

  • 0
какой тип данных выбрать для поля зарплата в бд mysql ? и почему ?

Ответы на такие вопросы ищутся в документации к СУБД, а не на форумах...

http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html

The DECIMAL and NUMERIC data types are used to store exact numeric data values. In MySQL, NUMERIC is implemented as DECIMAL. These types are used to store values for which it is important to preserve exact precision, for example with monetary data.

MySQL 5.1 stores DECIMAL and NUMERIC values in binary format. Before MySQL 5.0.3, they were stored as strings. See Section 11.14, “Precision Math”.

When declaring a DECIMAL or NUMERIC column, the precision and scale can be (and usually is) specified; for example:

salary DECIMAL(5,2)

In this example, 5 is the precision and 2 is the scale. The precision represents the number of significant digits that are stored for values, and the scale represents the number of digits that can be stored following the decimal point. If the scale is 0, DECIMAL and NUMERIC values contain no decimal point or fractional part.

Standard SQL requires that the salary column be able to store any value with five digits and two decimals. In this case, therefore, the range of values that can be stored in the salary column is from -999.99 to 999.99.

Link to comment
Share on other sites

  • 0
Ответы на такие вопросы ищутся в документации к СУБД, а не на форумах...

http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html

да, но почему именно decimal ? в чем разница, вон народу сколько все деньги в float хранят B) и ничего ;)

Link to comment
Share on other sites

  • 0
да, но почему именно decimal ? в чем разница, вон народу сколько все деньги в float хранят :) и ничего :)

The FLOAT and DOUBLE data types are used to represent approximate numeric data values.

The DECIMAL and NUMERIC data types are used to store exact numeric data values. In MySQL, NUMERIC is implemented as DECIMAL. These types are used to store values for which it is important to preserve exact precision, for example with monetary data.

Link to comment
Share on other sites

  • 0
The FLOAT and DOUBLE data types are used to represent approximate numeric data values.

The DECIMAL and NUMERIC data types are used to store exact numeric data values. In MySQL, NUMERIC is implemented as DECIMAL. These types are used to store values for which it is important to preserve exact precision, for example with monetary data.

да-да-да.. а кто-то видел когда-нибудь чтобы в базе хранились данные отличные от исходных?) я вот не думаю что у кого-то ставка допустим $800.0001 B) это круглые числа - вам не кажется?)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy