

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Change value of decimal(19, 2) when inserting into the database in MySQL?
To store the exact real value, you need to use truncate() with 2 decimal point. Let us create a table −
Following is the query to create a table.
mysql> create table demo59 −> ( −> price decimal(19,2) −> ); Query OK, 0 rows affected (1.12 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo59 values(truncate(15.346, 2)); Query OK, 1 row affected (0.14 sec) mysql> insert into demo59 values(truncate(20.379, 2)); Query OK, 1 row affected (0.72 sec) mysql> insert into demo59 values(truncate(25.555, 2)); Query OK, 1 row affected (0.16 sec) mysql> insert into demo59 values(truncate(100.456, 2)); Query OK, 1 row affected (0.21 sec)
Display records from the table using select statement −
mysql> select *from demo59;
This will produce the following output −
+--------+ | price | +--------+ | 15.34 | | 20.37 | | 25.55 | | 100.45 | +--------+ 4 rows in set (0.00 sec)
- Related Questions & Answers
- Can we skip column when inserting into MySQL?
- How to insert DECIMAL into MySQL database?
- Display the warning message when a FLOAT value is inserted into DECIMAL in MySQL?
- Inserting Array list into HANA database
- Insert NULL value into database field with char(2) as type in MySQL?
- Inserting random numbers into a table in MySQL?
- Java application to insert null value into a MySQL database?
- Change the decimal point of every value in an R data frame column.
- How to store the PayPal decimal amount in the MySQL database?
- How can we change the default MySQL database to the given database?
- Inserting records into a MySQL table using PreparedStatement in Java?
- Get the date/time of the last change to a MySQL database?
- Change max_heap_table_size value in MySQL?
- Inserting an Element into Deaps
- Inserting data into a new column of an already existing table in MySQL?
Advertisements