SQLite Forum

The NUMERIC data type?
Because the documentation for different implementations of SQL argue over this, I'm going to start by defining what I think NUMERIC() means.  The format is

<pre>NUMERIC(p,s) where
p == precision == the maximum number of decimal digits to store
s == scale == the number of those digits to the right of the decimal point</pre>

so the widest number which could be stored with <code>NUMERIC(10,2)</code> would be <code>12341234.12</code>.  Unlike the DECIMAL() type, maths on NUMERIC() values does not have to be perfectly respectful of decimal accuracy.

You can use NUMERIC.  (You can include (p,s) at the end but it will be completely ignored.). It will do something useful.  But you may want to avoid this so that values are never stored as strings.

The nearest types used by SQLite are REAL and INTEGER.  For <code>NUMERIC(p,s)</code> where s = 0, I would use INTEGER.  For others, I'd use REAL.  Alternatively you might like to choose a type which fits the type of variable you're using in your programming language.  So if, for example, you want to use C variables of type 'float' you would use REAL, even if you expect to store only integers.