Database Viewer
Browse the SQL that builds any database used across the lessons, without running it.
Loaded: Example 2 indexed database ยท introduction-to-indexes.indexed-database-init
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL,
city TEXT NOT NULL
);
-- Add an index so PostgreSQL can find rows by email
-- without scanning the whole table.
CREATE INDEX users_email_idx ON users (email);
INSERT INTO users (name, email, city)
SELECT
'User ' || value,
'user' || value || '@example.com',
CASE value % 4
WHEN 0 THEN 'London'
WHEN 1 THEN 'Paris'
WHEN 2 THEN 'Berlin'
ELSE 'Madrid'
END
FROM generate_series(1, 10000) AS value;
ANALYZE users;