Nearby lessons

28 of 37

JDBC - 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
Loading editor…

Common MySQL Data Types

Data typeWhat it storesExample
INTWhole numbersid, age, quantity
VARCHAR(n)Text up to n charactersname, city, email
DOUBLEDecimal numberssalary, price
DATEA calendar datehiredate, dob
BOOLEANtrue / falseactive, 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 INT column named id.
  • 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
Loading editor…
📝 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

Finished this lesson?

Mark it as complete to track your progress and see technology completion stats.