如何使用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)
热门推荐
4 薛之谦祝福语简短
10 新婚祝福语大全简短经典
11 撩妹生日祝福语简短
12 新年送老师简短祝福语
13 冬季祝福语大全 简短的
14 老同学十一祝福语简短
15 项目总生日祝福语简短
16 父亲简短结婚祝福语大全
17 简短祝福语中考女孩的话
18 简短创意祝福语有什么