如何使用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 婶婶生日贺词简短祝福语