MySQL DECIMAL डेटा टाइप का उपयोग सटीक न्यूमेरिकल वैल्यू स्टोर करने के लिए किया जा सकता है। DECIMAL डेटा टाइप का सिंटैक्स।
yourColumnName DECIMAL(integerValue, integerValue);
DECIMAL डेटा टाइप का उदाहरण।
mysql> create table EmployeeInformation -> ( -> EmpId int auto_increment primary key, -> EmpName varchar(200), -> EmpSalary DECIMAL(6,2) -> ); Query OK, 0 rows affected (0.54 sec)
जब भी हम "EmpSalary" कॉलम में 6 डिजिट से अधिक वैल्यू इन्सर्ट करते हैं, तो यह एरर देता है। एरर निम्न है −
mysql> insert into EmployeeInformation(EmpName, EmpSalary) values('John', 6999999.50);
ERROR 1264 (22003): Out of range value for column 'EmpSalary' at row 1
"EmpSalary" कॉलम में सटीक डिजिट्स की संख्या के साथ वैल्यू इन्सर्ट करना।
mysql> insert into EmployeeInformation(EmpName, EmpSalary) values('John', 6999.50);
Query OK, 1 row affected, 1 warning (0.15 sec)
mysql> insert into EmployeeInformation(EmpName, EmpSalary) values('John', 69999.50);
Query OK, 1 row affected, 1 warning (0.20 sec)
सभी रिकॉर्ड्स डिस्प्ले करने के लिए।
mysql> select * from EmployeeInformation;
आउटपुट निम्न है।
+-------+---------+-----------+ | EmpId | EmpName | EmpSalary | +-------+---------+-----------+ | 1 | John | 7000.00 | | 2 | John | 70000.00 | +-------+---------+-----------+ 2 rows in set (0.00 sec)