1.5 Data Types Flashcards
data type
A data type is a named set of values from which column values are drawn.
Integer
INT
Integer data types represent positive and negative integers.
Decimal
DECIMAL(M,D)
FLOAT (4 Bytes)
DOUBLE (8 Bytes)
Decimal data types represent numbers with fractional values.
Character
CHAR(N) - fixed length
VARCHAR(N) - variable lengh
TEXT
Character data types represent textual characters.
Date and time
DATE
TIME
DATETIME
Date and time data types represent date, time, or both. Some date and time data types include a time zone or specify a time interval.
Binary
Binary data types store data exactly as the data appears in memory or computer files, bit for bit.
Spatial
Spatial data types store geometric information, such as lines, polygons, and map coordinates.
Document
Document data types contain textual data in a structured format such as XML or JSON.
signed
includes a - sign
A signed number may be negative.
unsigned
An uNsigned number canNot be Negative.
enum
Each value in the ENUM list is stored as a number internally, but it’s displayed as text. This is efficient for small, predefined lists, making it ideal for cases like days of the week, months, or product statuses.
If an attempt is made to insert a value outside of this set, the database will reject it.
CREATE TABLE Colors (
Color ENUM(‘Red’, ‘Green’, ‘Blue’)
);