
All values in a column of type CHAR(4), for example, must contain exactly 4 characters. The type CHAR is followed by parentheses enclosing the length of the string.

The type CHARACTER, usually abbreviated as CHAR, is used for fixed-length strings.
#Sqlite data types full
See Appendix B - Character string types for a full discussion of character string types. There are several data types for storing character data in SQL again, actual implementations vary. These types can support extremely large and extremely small numbers, and are most useful in scientific and mathematical applications. The SQL standard defines the types FLOAT, REAL, and DOUBLE PRECISION (often abbreviated DOUBLE), but implementation of these types vary. Floating point numbers ¶įloating point number types allow for a possibly inexact storage of real numbers, similar (or sometimes identical to) the IEEE 754 specification. This may result in an error, or (in the case of too many digits to the right of the decimal point), it may result in rounding or truncation of the value.ĭecimal number types are particularly important for the storage of monetary data, where exact addition, subtraction, and multiplication is necessary. NUMERIC defines a type that can exactly store decimal values with implementation-defined precision and scale.ĭifferent implementations behave differently when an attempt is made to store values with more digits than are allowed by the specified precision and scale. NUMERIC(4) defines a type that can store integers between -99. NUMERIC(3, 2) defines a type that can store the values between -999.99 and 999.99, with a maximum of 2 digits past the decimal point. If the precision is given, but not the scale, the scale defaults to zero. These types may be defined with parameters representing precision and scale, where precision is the number of significant digits that can be stored, and scale is the number of digits following the decimal point. The two defined types for SQL are NUMERIC and DECIMAL, which are synonyms of each other. These numbers are exact (unlike the floating point types described below) and permit exact mathematical operations where possible (addition, subtraction, and multiplication). Exact decimal numbers ¶ĭecimal number types allow for exact storage of numbers that have digits to the right of the decimal point, e.g., 1234.56789. Additional integer types may be available for your database system. Not all databases recognize all of these types, but INTEGER is recognized by all of the databases considered for this book. Implementations of these types vary, but it is not uncommon for INTEGER (often abbreviated as INT) to store 32-bit integers, SMALLINT 16-bit integers, and BIGINT 64-bit integers. SQL defines three integer types: INTEGER, SMALLINT, and BIGINT. However, actual implementation of the standard varies quite a bit see Appendix B - Number types for a full discussion of number types. SQL provides support for several different types of numbers, each with different applications and limitations. In this section we survey the major data types, without discussion of database compatibility for more information, see Appendix B - Data types. For all of these reasons, you will want to consult your database system’s documentation to understand the types available to you. Unusually, SQLite is dynamically typed, and you can store values of any type in any column no matter how the column is defined. Most database systems define additional, non-standard types for various uses.

While most of the basic types exist in all relational database systems, actual implementation of the types varies quite a bit.

The SQL standard defines several basic data types with which columns can be associated. This chapter will discuss basic table creation, starting with an explanation of SQL data types.
