Day 2:SQL

Published: (December 14, 2025 at 06:25 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Database Structure, Data Types & Table Basics

1. Database Structure Recap

A Relational Database contains:

  • Database
  • Tables
  • Rows (Records)
  • Columns (Fields)

Example

  • Database → school
  • Table → students
  • Columns → student_id, name, age, city

2. SQL Data Types (VERY IMPORTANT)

Numeric Data Types

Data TypeDescriptionExample
INTWhole numbers10, 25
BIGINTLarge integers1 000 000
DECIMAL(p,s)Decimal numbers99.50

String / Character Data Types

Data TypeDescriptionExample
CHAR(n)Fixed‑length text'A'
VARCHAR(n)Variable‑length text'Aruna'
TEXTLarge textAddress

Date & Time Data Types

Data TypeDescriptionExample
DATEYYYY‑MM‑DD2025-01-10
TIMEHH:MM:SS10:30:00
DATETIMEDate + Time2025-01-10 10:30:00

3. CREATE TABLE with Data Types

CREATE TABLE employees (
    emp_id    INT,
    emp_name  VARCHAR(50),
    salary    DECIMAL(10,2),
    join_date DATE
);

4. Viewing Table Structure

  • Describe a table
DESCRIBE employees;
  • Show all tables
SHOW TABLES;

5. INSERT Data (Detailed)

  • Insert a single row
INSERT INTO employees (emp_id, emp_name, salary, join_date)
VALUES (101, 'Ravi', 35000.50, '2024-06-15');
  • Insert multiple rows
INSERT INTO employees VALUES
(102, 'Priya', 42000.00, '2024-07-01'),
(103, 'Karthik', 38000.75, '2024-08-10');

6. SELECT Basics (More Detail)

  • Select all columns
SELECT * FROM employees;
  • Select specific columns
SELECT emp_name, salary FROM employees;

7. Table Naming Rules

  • Use meaningful names.
  • Avoid SQL keywords.
  • Prefer lowercase with underscores.

Correct: employee_details
Incorrect: select, table

Back to Blog

Related posts

Read more »

Day 2:Python Programming

Database Structure, Data Types & Table Basics 1. Database Structure Recap A Relational Database contains: - Database - Tables - Rows Records - Columns Fields E...