Create Table With UUIDs

Install UUID Extension

-- Install uuid extension
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"

Create Table

-- Create table called adventurers
CREATE TABLE adventurers (
    -- uuid variable
    adventurer_id uuid DEFAULT uuid_generate_v4(),
    -- string variable
    name varchar(255),
    -- integer variable
    age int,
    -- string variable
    race varchar(255),
    -- string variable
    weapon varchar(255),
    -- Assign adventurer_id as primary key
    PRIMARY KEY (adventurer_id)
)

Insert Rows

-- Insert into the table adventurers
INSERT INTO adventurers (name, age, race, weapon)
VALUES ('Fjoak Doom-Wife', 28, 'Human', 'Axe'),
       ('Alooneric Cortte', 29, 'Human', 'Bow'),
       ('Piperel Ramsay', 35, 'Elf', 'Bow'),
       ('Casimir Yardley', 14, 'Elf', 'Bow')

View Table

-- Retrieve all rows in table
SELECT * FROM adventurers
adventurer_idnameageraceweapon
61bf9084-2fcc-40dd-bbec-08de205e7877Fjoak Doom-Wife28HumanAxe
495c81ca-a49d-4848-84bc-01bfa27916ccAlooneric Cortte29HumanBow
1533f42e-e64b-4aa2-8432-926defe3d248Piperel Ramsay35ElfBow
090420af-372c-43b8-9eda-763a76eb692fCasimir Yardley14ElfBow