Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Beyond numbers, text, and dates, MySQL provides specialized data types designed for specific software engineering patterns: ENUM for restricted choice lists, BOOLEAN for true/false flags, and JSON for modern semi-structured document storage.
ENUM: Constrained String ChoicesAn ENUM is a string object whose value must be chosen from an explicit list of permitted values declared at table creation time:
'High'), MySQL stores them internally as 1-byte or 2-byte integers representing index positions ('Low' = 1, 'Medium' = 2, 'High' = 3, 'Critical' = 4).ENUM extremely compact on disk and fast to compare.'Urgent'), MySQL in strict mode rejects the query with an error!ENUM if the list of values changes frequently! Adding a new value to an ENUM requires an ALTER TABLE statement. If values change often, use a separate lookup table with a foreign key instead.BOOLEAN / BOOL: Truth Values in MySQLDoes MySQL have a true native Boolean type? No!
In MySQL, BOOLEAN and BOOL are syntactic synonyms for TINYINT(1):
TRUE evaluates to the integer 1.FALSE evaluates to the integer 0.JSON Data Type in MySQL 8.0+MySQL provides native support for RFC 7159 JSON documents. Unlike storing JSON as a raw TEXT string, MySQL's native JSON data type:
-> and ->>)-> (JSON Extract): Extracts value preserving JSON quotes (e.g., "Apple").->> (JSON Unquote Extract): Extracts value as clean unquoted text (e.g., Apple).WHERE specifications->'$.brand' = 'Apple'), create a virtual generated column on that JSON path and put a standard B-Tree index on it!BOOLEAN internally an alias for?ENUM('Small', 'Medium', 'Large') column on disk?-> and ->> JSON extraction operators in MySQL?JSON type superior to storing JSON in a standard TEXT column?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Date & Time Types | Creating Tables Syntax & Rules |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.