Skip to content

Commit fa08bb2

Browse files
committed
docs: add "Notes on Data Types"
1 parent 5bbf3af commit fa08bb2

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

user_guide_src/source/dbmgmt/forge.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,40 @@ After the fields have been defined, they can be added using
120120
``$forge->addField($fields)`` followed by a call to the
121121
``createTable()`` method.
122122

123+
Notes on Data Types
124+
-------------------
125+
126+
Floating-Point Types
127+
^^^^^^^^^^^^^^^^^^^^
128+
129+
Floating-Point types such as ``FLOAT`` and ``DOUBLE`` represent approximate values.
130+
Therefore, they should not be used when exact values are needed.
131+
132+
::
133+
134+
mysql> CREATE TABLE t (f FLOAT, d DOUBLE);
135+
mysql> INSERT INTO t VALUES(99.9, 99.9);
136+
137+
mysql> SELECT * FROM t WHERE f=99.9;
138+
Empty set (0.00 sec)
139+
140+
mysql> SELECT * FROM t WHERE f > 99.89 AND f < 99.91;
141+
+------+------+
142+
| f | d |
143+
+------+------+
144+
| 99.9 | 99.9 |
145+
+------+------+
146+
1 row in set (0.01 sec)
147+
148+
When it is important to preserve exact precision, for example with monetary data,
149+
``DECIMAL`` or ``NUMERIC`` should be used.
150+
151+
TEXT
152+
^^^^
153+
154+
``TEXT`` should not be used on SQLSRV. It is deprecated.
155+
See `ntext, text, and image (Transact-SQL) - SQL Server | Microsoft Learn <https://learn.microsoft.com/en-us/sql/t-sql/data-types/ntext-text-and-image-transact-sql?view=sql-server-ver16>`_.
156+
123157
$forge->addField()
124158
------------------
125159

0 commit comments

Comments
 (0)