MySQL tablolarında FLOAT tipinde bir alana length (precision) değeri vermeden oluşturunca rakamları 7 hanede kesiyor. Bunu simüle etmek için aşağıdaki şekilde bir deneme yaptım:

 

[sql]

DROP TABLE IF EXISTS `float_test`;

CREATE TABLE IF NOT EXISTS `float_test` (
`string_field` varchar(50) NOT NULL,
`float_field` float NOT NULL
) ENGINE=InnoDB;

INSERT INTO float_test (string_field, float_field) VALUES (‘1’, 1);
INSERT INTO float_test (string_field, float_field) VALUES (‘1.2’, 1.2);
INSERT INTO float_test (string_field, float_field) VALUES (‘1.23’, 1.23);
INSERT INTO float_test (string_field, float_field) VALUES (‘1.234’, 1.234);
INSERT INTO float_test (string_field, float_field) VALUES (‘1.2345’, 1.2345);
INSERT INTO float_test (string_field, float_field) VALUES (‘1.23456’, 1.23456);
INSERT INTO float_test (string_field, float_field) VALUES (‘1.234567’, 1.234567);
INSERT INTO float_test (string_field, float_field) VALUES (‘1.2345678’, 1.2345678);
INSERT INTO float_test (string_field, float_field) VALUES (‘1.23’, 1.23);
INSERT INTO float_test (string_field, float_field) VALUES (‘12.34’, 12.34);
INSERT INTO float_test (string_field, float_field) VALUES (‘123.45’, 123.45);
INSERT INTO float_test (string_field, float_field) VALUES (‘1234.56’, 1234.56);
INSERT INTO float_test (string_field, float_field) VALUES (‘12345.67’, 12345.67);
INSERT INTO float_test (string_field, float_field) VALUES (‘123456.78’, 123456.78);
INSERT INTO float_test (string_field, float_field) VALUES (‘1234567.89’, 1234567.89);

SELECT * FROM float_test;

[/sql]

ve sonuç aşağıdaki gibi çıktı:

+--------------+-------------+
| string_field | float_field |
+--------------+-------------+
| 1            |           1 |
| 1.2          |         1.2 |
| 1.23         |        1.23 |
| 1.234        |       1.234 |
| 1.2345       |      1.2345 |
| 1.23456      |     1.23456 |
| 1.234567     |     1.23457 |
| 1.2345678    |     1.23457 |
| 1.23         |        1.23 |
| 12.34        |       12.34 |
| 123.45       |      123.45 |
| 1234.56      |     1234.56 |
| 12345.67     |     12345.7 |
| 123456.78    |      123457 |
| 1234567.89   |     1234570 |
+--------------+-------------+