What is the datatype for currency in MySQL?

What is the datatype for currency in MySQL?

From the MySQL manual: The DECIMAL and NUMERIC types store exact numeric data values. These types are used when it is important to preserve exact precision, for example with monetary data. In MySQL, NUMERIC is implemented as DECIMAL, so the following remarks about DECIMAL apply equally to NUMERIC.

How to choose data types?

The general rule of thumb for choosing a data type for the columns in your tables is to choose the data type that most closely matches the domain of correct values for the column. That means you should try to adhere to the following rules: If the data is numeric, favor SMALLINT, INTEGER, BIGINT, or DECIMAL data types.

How do you choose data types for efficient queries?

Data Type Choices and Query Efficiency

  1. Don’t use longer columns when shorter ones will do.
  2. If you have a choice about row storage format, use one that is optimal for your storage engine.
  3. Define columns to be NOT NULL.
  4. Consider using ENUM columns.
  5. Use PROCEDURE ANALYSE().

What is the datatype for money?

Although MONEY can be represented with a currency symbol, this information isn’t stored. Under the covers, MONEY is stored as an integer data type. A decimal number, the more usual choice for storing a monetary value, can range accurately between -10^38 +1 through 10^38 – 1.

Which is datatype should be used for currency?

Numeric with forced 2 units precision. Never use float or float like datatype to represent currency because if you do, people are going to be unhappy when the financial report’s bottom line figure is incorrect by + or – a few dollars. The money type is just left in for historical reasons as far as I can tell. Your source is in no way official.

What are the different types of currency fields?

More information: Using the right type of number Monetary values between -922,337,203,685,477 and 922,337,203,685,477 can be in this field. You can set a level of precision or choose to base the precision on a specific currency or a single standard precision used by the organization. More information: Using Currency Fields

How to save a list of currencies in PHP?

Using a char (3) field and saving the currencies as usd, cad, etc. Using a tinyint field and relating this to another database that holds the iso code for each currency. Using a tinyint field and instead of relating a database (and having to do JOINs), I just save the list of very static and non-changing currencies in a PHP array.

What are the different types of field data?

Contains an aggregate value computed from the records related to a record, or a value computed over a hierarchy. The following table contains information about the field data types.