Create tables
SQL Editor → New query → paste → Run
create table authors (
id bigint generated always as identity primary key,
name text not null
);
create table books (
id bigint generated always as identity primary key,
author_id bigint references authors(id),
title text not null,
is_published boolean default true
);
idnumbers itselfreferenceslinks a book to its author
Add data
- By hand: Table Editor → table → Insert row
- From spreadsheet: Insert → Import data from CSV (column names must match)
- With SQL:
insert into authors (name) values ('Author One');
insert into books (author_id, title) values (1, 'First Book');
Read data
select * from books;
-- search
select title from books where title ilike '%book%';
Change a table (don’t recreate)
alter table books add column year int;
Common errors
does not exist: create the table firstalready exists: already done, skip it- Use a fresh empty tab for each script
