They are the same for almost all purposes.
At one time different vendors used different names (Numeric/Decimal) for almost the same thing. SQL-92 made them the same with one minor difference which can be vendor specific:
NUMERIC must be exactly as precise as it is defined — so if you define 4 decimal places, the DB must always store 4 decimal places.
DECIMAL must be at least as precise as it is defined. This means that the database can actually store more digits then specified (due to the behind-the-scenes storage having space for extra digits). This means the database might store
1.00005 instead of 1.0000, affecting future calculations.
In SQL Server Numeric is defined as being identical to Decimal in every way — both will always store only the specified number of decimal places.
本文探讨了SQL中NUMERIC与DECIMAL数据类型的细微差别。虽然二者在大多数情况下相同,但NUMERIC要求精确指定小数位数,而DECIMAL允许数据库存储比定义更多的数字,这可能会影响后续计算。
533

被折叠的 条评论
为什么被折叠?



