How To Add Money Amount In Mysql
What is the best data type to shop coin values in MySQL?
We tin store the money values in MySQL in decimal(value1,value2). Hither, value1 is the full range including value2. The value2 specifies the number of digits after the decimal point. To understand this concept, the steps are given beneath.
First a table is created using the create command.
mysql> CREATE table MoneyDemo -> ( -> Id int, -> Money decimal(10,2) -> ); Query OK, 0 rows affected (0.46 sec)
As tin can be seen from the above command, the decimal value has ten digits only and as well ii digits only after the decimal point.
After creating the tabular array, some records are inserted with the aid of the insert command. This is given equally follows −
mysql> INSERT into MoneyDemo values(1,98777445.50); Query OK, 1 row affected (0.thirteen sec) mysql> INSERT into MoneyDemo values(two,12345678.00); Query OK, i row affected (0.18 sec) mysql> INSERT into MoneyDemo values(3,88888888.50); Query OK, i row affected (0.20 sec)
If more than 10 digits are inserted in the in a higher place commands, an error message will exist generated. This can exist seen below −
mysql> INSERT into MoneyDemo values(3,8888888888.50); Mistake 1264 (22003): Out of range value for cavalcade 'Money' at row one
All the records in the table can exist displayed with the assistance of the select statement. The query for this is given below −
mysql> SELECT * from MoneyDemo;
The output obtained is as follows
+------+-------------+ | Id | Money | +------+-------------+ | i | 98777445.l | | 2 | 12345678.00 | | 3 | 88888888.l | +------+-------------+ 3 rows in set (0.00 sec)
Published on xviii-Oct-2018 09:35:xiv
- Related Questions & Answers
- The best information blazon to shop 0, 1, null values in MySQL?
- What is the all-time manner to earn coin online?
- Best data type for storing currency values in a MySQL database?
- What is the all-time site to invest money in stock market?
- What is the best data type to use for currency in C#?
- What is MySQL ENUM data type? What are the advantages to use ENUM information blazon?
- What is Blob data blazon in MySQL?
- What is TEXT data blazon in MySQL?
- What is JDBC Blob data type? how to store and read information from it?
- What is JDBC Clob data type? how to shop and read information from it?
- What is the data type for unix_timestamp in MySQL?
- Best data type for storing large strings in MySQL?
- All-time fashion to shop weekly outcome in MySQL?
- Which MySQL Data Type can exist used to store Negative Number?
- How should I store information into my Mysql database, what type should I assign to a column storing salt values?
How To Add Money Amount In Mysql,
Source: https://www.tutorialspoint.com/what-is-the-best-data-type-to-store-money-values-in-mysql
Posted by: rossoffied.blogspot.com
0 Response to "How To Add Money Amount In Mysql"
Post a Comment