Ravindra BagaleCourses & study guides मराठी Track your progress

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

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
Creating Tables and Choosing Data Types · Download PNG
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).

TypeStoresExample
INT / BIGINTWhole numbersid, age
DECIMAL(10,2)Exact money valuesfees
VARCHAR(n)Text up to n charactersname VARCHAR(100)
TEXTLong textcaption
DATE / DATETIME / TIMESTAMPDates and timesjoined_on DATE

Learn more in the lesson: 10.3 Creating Tables and Choosing Data Types

See all Ravi Sir's Cyber Security Cards