-- Create a sequence to provide an integer primary key for the table
DROP SEQUENCE IF EXISTS id_sequence CASCADE;
CREATE SEQUENCE id_sequence START 1;
-- Create the users table
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id INTEGER DEFAULT nextval('id_sequence'),
username VARCHAR(50) NOT NULL UNIQUE,
email VARCHAR(100) NOT NULL UNIQUE,
full_name VARCHAR(100) NOT NULL,
age INTEGER,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert 10 rows of test data
INSERT INTO users (username, email, full_name, age) VALUES
('john_doe', '[email protected]', 'John Doe', 30),
('jane_smith', '[email protected]', 'Jane Smith', 28),
('bob_johnson', '[email protected]', 'Bob Johnson', 35),
('alice_williams', '[email protected]', 'Alice Williams', 26),
('charlie_brown', '[email protected]', 'Charlie Brown', 22),
('diana_miller', '[email protected]', 'Diana Miller', 31),
('eric_davis', '[email protected]', 'Eric Davis', 29),
('fiona_taylor', '[email protected]', 'Fiona Taylor', 33),
('george_wilson', '[email protected]', 'George Wilson', 27),
('hannah_moore', '[email protected]', 'Hannah Moore', 24);
SELECT * FROM users
Practice DuckDB SQL commands using DuckDB in WASM
Credit: duckdb/duckdb-pyodide