Ravi Sir's Cyber Security Cards › Revision Cards
Creating Tables and Choosing Data Types
Creating Tables and Choosing Data Types CREATE TABLE makes a table. Each column gets a data type : INT (whole numbers), VARCHAR (text), DATE, DECIMAL (money). CREATE TABLE students (id INT PRIMARY KEY, name VARCHAR(100), fees DECIMAL(10,2)); A VARCHAR(20) password column means you plan to store plai

Read card text
What this card says
What it is
CREATE TABLE makes a table. Each column gets a data type: INT (whole numbers), VARCHAR (text), DATE, DECIMAL (money).
Example
CREATE TABLE students (id INT PRIMARY KEY, name VARCHAR(100), fees DECIMAL(10,2));
Common mistake
A VARCHAR(20) password column means you plan to store plain passwords.
Never do that. Hash with PHP password_hash() and store it in VARCHAR(255).
| Type | Stores | Example |
|---|---|---|
| INT / BIGINT | Whole numbers | id, age |
| DECIMAL(10,2) | Exact money values | fees |
| VARCHAR(n) | Text up to n characters | name VARCHAR(100) |
| TEXT | Long text | caption |
| DATE / DATETIME / TIMESTAMP | Dates and times | joined_on DATE |
Learn more in the lesson: 10.3 Creating Tables and Choosing Data Types