JSTAcademy
0 XP
Dashboard
Crash Courses
PostgreSQL Fundamentals
10 min
Basic+150 XP
Crash Courses · Basic

PostgreSQL Fundamentals

Write SELECT, INSERT, UPDATE, DELETE and understand Postgres data types.
10 min read+150 XP on completionCert: PostgreSQL Crash Course
Tap any word in the text below to start reading from there.

PostgreSQL Fundamentals

PostgreSQL is the world's most advanced open-source relational database. Supabase runs on Postgres understanding SQL gives you full control.

SELECT

-- All columns
SELECT * FROM courses;

-- Specific columns with alias
SELECT id, title, xp AS experience_points FROM courses;

-- Filter
SELECT * FROM courses WHERE track = 'crash' AND level = 'Basic';

-- Sort and limit
SELECT * FROM courses
ORDER BY xp DESC
LIMIT 10;

-- Range
SELECT * FROM courses WHERE xp BETWEEN 150 AND 200;

-- Pattern match
SELECT * FROM courses WHERE title ILIKE '%react%';  -- case-insensitive

INSERT

-- Single row
INSERT INTO progress (user_id, course_id, xp_earned)
VALUES ('uuid-here', 'cc-js-m01', 150)
RETURNING id, completed_at;

-- Multiple rows
INSERT INTO progress (user_id, course_id, xp_earned) VALUES
  ('uuid1', 'cc-js-m01', 150),
  ('uuid1', 'cc-js-m02', 150);

UPDATE

UPDATE profiles
SET display_name = 'Jordan', updated_at = now()
WHERE id = 'uuid-here'
RETURNING id, display_name;

DELETE

-- Delete with filter (always use WHERE)
DELETE FROM sessions
WHERE expires_at < now()
RETURNING id;

-- TRUNCATE — deletes all rows fast (no WHERE, not logged row by row)
TRUNCATE TABLE temp_data;
0%