Skip to main content
Albero Academy

CREATE TABLE & Data Types

Define tables and choose the right column types.

Data & Schema9 min

CREATE TABLE defines a table's structure — each column's name, type and constraints. Choosing the right data type keeps data correct and storage efficient (this is DDL — data definition language).

Creating a table

define structure
CREATE TABLE students (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
email VARCHAR(150) UNIQUE,
package DECIMAL(5,2) DEFAULT 0.00,
enrolled DATE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Common types

TypeUse for
INT / BIGINTWhole numbers, IDs
DECIMAL(p,s)Exact money/measures (never FLOAT for money)
VARCHAR(n)Short, variable-length text
TEXTLong text
DATE / TIMESTAMPDates and times
BOOLEANTrue/false

Key takeaways

  1. 01CREATE TABLE defines columns, types and constraints (DDL).
  2. 02Match the type to the data: INT for IDs, VARCHAR for text, DATE/TIMESTAMP for time.
  3. 03Use DECIMAL for money — never FLOAT/DOUBLE.
  4. 04ALTER TABLE modifies structure later; DROP TABLE deletes the table.

Finished this chapter?

Mark it complete to track your progress through SQL.