如何使用MySQL十进制?
MySQL十进制数据类型可用于存储确切的数值。DECIMAL数据类型的语法。
yourColumnName Decimal(integerValue,intgerValue);
DECIMAL数据类型的示例。
mysql> create table EmployeeInformation -> ( -> EmpId int auto_increment primary key, -> EmpName varchar(200), -> EmpSalary DECIMAL(6.2) -> );
每当我们在“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);
mysql> insert into EmployeeInformation(EmpName,EmpSalary) values('John',69999.50);显示所有记录。
mysql> select *from EmployeeInformation;
以下是输出。
+-------+---------+-----------+ | EmpId | EmpName | EmpSalary | +-------+---------+-----------+ | 1 | John | 7000 | | 2 | John | 70000 | +-------+---------+-----------+ 2 rows in set (0.00 sec)
热门推荐
10 祝孙辈生日祝福语简短
11 恋人跨年祝福语大全简短
12 考大学敬酒简短祝福语
13 开工投产大吉祝福语 简短
14 偶然结婚祝福语朋友简短
15 感谢学长学姐祝福语简短
16 戏精的祝福语简短
17 我要结婚祝福语简短
18 婚前女儿生日祝福语简短