Knowledge Guide
HomeDatabasesSQL Fundamentals

CREATE

CREATE

In SQL, the CREATE statement is used to create various database objects, i.e., tables, indexes, or the database itself.

Here's a detailed explanation of the CREATE statement and the objects you can create.

  1. CREATE Database

We can create a new database with a CREATE statement. Let's see how.

CREATE DATABASE database_name;

This simple command will create a database. You can specify any name for your database.

  1. CREATE Table

A table is a fundamental database object that stores and organizes data in a structured format. After creating a database, you first need to create a table so that you can act on it.

Here's how you can create a table in the database

CREATE TABLE Student ( StudentID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), RollNumber INT, );

You might be wondering what INT or VARCHAR means. Let's first go deeply into these fundamentals to ensure you have a firm grasp.

Data Types in SQL

SQL offers several data types to facilitate the specification of the kind of data to be stored in the table columns. For example, The age must be entered as a number, and the name must be entered as a string.

MySQL has three main data types: string, numeric, and date and time.

Data TypeDescriptionExampleUse Case
Numeric Types
INTInteger data typeQuantity INTRepresenting counts, identifiers, or indices
BIGINTLarger integer typePopulation BIGINTHandling large numbers, like population counts
SMALLINTSmaller integer typeRank SMALLINTLimited range integer values, e.g., rank
DECIMAL(p, s)Decimal numbers with precision and scalePrice DECIMAL(10, 2)Monetary values with exact precision
Character String Types
VARCHAR(n)Variable-length character stringsName VARCHAR(50)Storing variable-length text
CHAR(n)Fixed-length character stringsCode CHAR(10)Fixed-length codes or identifiers
TEXTVariable-length character strings for large text dataDescription TEXTStoring large text or document content
Date and Time Types
DATEDate without a time componentBirthDate DATEBirthdates, event dates
TIMETime without a date componentEventTime TIMERecording time of events
DATETIME or TIMESTAMPDate and time togetherCreatedAt TIMESTAMPTimestamps for record creation or updates
YEARYear in a four-digit formatBirthYear YEARStoring years, e.g., year of birth

The (n) notation in the CHAR and VARCHAR types represents the maximum length of the string.

So, as we go through the concepts in detail, now you know that VARCHAR or INT is just the type of data that needs to be stored in a specific column in the student table.

🤖 Don't fully get this? Learn it with Claude

Stuck on CREATE? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **CREATE** (Databases) and want to truly understand it. Explain CREATE from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **CREATE** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **CREATE** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **CREATE** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes