Nearby lessons
28 of 37JDBC - Create Tables
📌 What You Will Learn
- Create tables with the CREATE TABLE statement
- Pick column names and data types
- Understand the PRIMARY KEY
Learn the CREATE TABLE statement — column names, MySQL data types, and the PRIMARY KEY that makes each row unique.
The CREATE TABLE Statement
A table is made of columns (the fields) and will later hold rows (the records). Each column needs a name and a data type:
Example01
Common MySQL Data Types
| Data type | What it stores | Example |
|---|---|---|
INT | Whole numbers | id, age, quantity |
VARCHAR(n) | Text up to n characters | name, city, email |
DOUBLE | Decimal numbers | salary, price |
DATE | A calendar date | hiredate, dob |
BOOLEAN | true / false | active, verified |
The PRIMARY KEY
The PRIMARY KEY column is special — every value in it must be unique and never empty. It is how you identify one specific row:
- No two rows can share the same primary-key value.
- It is usually an
INTcolumn namedid. - It is the column you use in
WHERE id = ...to update or delete one row.
Check the Table Structure
Describe shows the columns and types of a table:
Example04
📝 Key Takeaways
- CREATE TABLE defines the columns of a table
- Every column has a name and a data type
- The PRIMARY KEY column uniquely identifies each row