INTEGER
The column type for whole numbers, used in this course for keys, quantities and money stored in cents.
In more detail
Integers are exact: adding and multiplying them never introduces rounding errors, which is why prices are stored as a whole number of cents. In SQLite, a column declared INTEGER PRIMARY KEY becomes the row's built-in identifier and is assigned automatically when you insert a row without one.
Example
price_cents INTEGER NOT NULL CHECK (price_cents > 0)Related terms
- data type — The kind of a value, such as a whole number, text or a date, which decides what you can do with it and how it compares and sorts.
- money in cents — The practice of storing money as a whole number of the smallest unit, such as cents, so sums are exact.
- primary key — The column, or columns, whose value uniquely identifies each row of a table and can never be NULL.
- floating-point number — A number with a fractional part stored in binary, which can only approximate most decimal values.
Taught in
- Why Tables And Relations Beat Files — PostgreSQL, Indexing & Relational Data Modeling
- Data Types And What To Choose — PostgreSQL, Indexing & Relational Data Modeling