时间:2021-07-01 10:21:17 帮助过:5人阅读
-- 建表mysql> CREATE TABLE vc (v VARCHAR(4), c CHAR(4));Query OK, 0 rows affected (0.29 sec)-- 插入数据mysql> INSERT INTO vc VALUES('ab ', 'ab ');Query OK, 1 row affected (0.09 sec)-- 查询mysql> SELECT CONCAT(v, '+'), CONCAT(c, '+') FROM vc;+----------------+----------------+| CONCAT(v, '+') | CONCAT(c, '+') |+----------------+----------------+| ab + | ab+ |+----------------+----------------+1 row in set (0.06 sec)
mysql> CREATE TABLE blob_test( -> id INT NOT NULL AUTO_INCREMENT, -> content TEXT, -> PRIMARY KEY (id))ENGINE=MyISAM;Query OK, 0 rows affected (0.34 sec)
插入一些数据后,数据文件大小为:
mysql> SELECT count(1) FROM blob_test;+----------+| count(1) |+----------+| 12288 |+----------+存储文件大小此时大于7M:
我们删除一些数据后,文件大小并没有变:
mysql> DELETE FROM blob_test WHERE id > 5000;Query OK, 7288 rows affected (0.16 sec)
当我们执行优化OPTIMIZE TABLE blob_test后,文件大小才缩小:
mysql> OPTIMIZE TABLE blob_test;+---------------------+----------+----------+----------+| Table | Op | Msg_type | Msg_text |+---------------------+----------+----------+----------+| mysqltest.blob_test | optimize | status | OK |+---------------------+----------+----------+----------+1 row in set (0.08 sec)
1. 浮点数存在误差问题;
2. 对货币等对精度敏感的数据,应采用定点数来表示或存储;
3. 若程序中用到浮点数,要注意其误差问题,尽量避免浮点数比较;
4. 注意浮点数中一些特殊值的处理。
不吝指正。