KEMBAR78
SQL 2 - Column Attributes CheatSheet | PDF
0% found this document useful (0 votes)
7 views2 pages

SQL 2 - Column Attributes CheatSheet

This cheat sheet outlines key MySQL column attributes, including value constraints like NOT NULL and UNIQUE, auto-increment handling, type-specific modifiers, and indexing options. It also covers invisible columns introduced in MySQL 8.0 and generated columns that can be virtual or stored. Each attribute is briefly defined to aid in database design and management.

Uploaded by

Harsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

SQL 2 - Column Attributes CheatSheet

This cheat sheet outlines key MySQL column attributes, including value constraints like NOT NULL and UNIQUE, auto-increment handling, type-specific modifiers, and indexing options. It also covers invisible columns introduced in MySQL 8.0 and generated columns that can be virtual or stored. Each attribute is briefly defined to aid in database design and management.

Uploaded by

Harsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MySQL Column Attributes Cheat Sheet

1. Value Constraints

- NOT NULL: Disallows NULL values

- NULL: Allows NULL values (default)

- DEFAULT: Sets a default value if not specified

- CHECK: Enforces a condition (e.g., CHECK(age >= 18))

- UNIQUE: All values must be different

- PRIMARY KEY: Unique + NOT NULL combination to identify each row

2. Auto & Identity Handling

- AUTO_INCREMENT: Automatically generates sequential numbers

- ON UPDATE CURRENT_TIMESTAMP: Automatically updates timestamp when a row is modified

3. Type-Specific Modifiers

- UNSIGNED: Numeric values must be zero or positive

- ZEROFILL: Pads numbers with leading zeros (e.g., 0007)

- BINARY: Case-sensitive string comparison for CHAR/VARCHAR

- CHARACTER SET: Sets specific character set (e.g., utf8mb4)

- COLLATE: Defines how strings are compared

4. Metadata & Indexing

- COMMENT: Adds notes to the column

- INDEX / KEY: Creates an index on the column

- FULLTEXT: Enables full-text search indexing

- SPATIAL: For indexing spatial (geographic) data

5. Invisible Columns (MySQL 8.0+)

- INVISIBLE: Column hidden from SELECT * (unless explicitly called)

- VISIBLE: Default behavior - column appears in results


MySQL Column Attributes Cheat Sheet

6. Generated Columns

- GENERATED ALWAYS AS (...): Defines computed values

- VIRTUAL: Computed at query time (default)

- STORED: Computed once and saved like normal column

You might also like