Create View

Create Table

-- Create table called adventurers
CREATE TABLE adventurers (
    -- string variable
    name varchar(255),
    -- integer variable
    age int,
    -- string variable
    race varchar(255),
    -- string variable
    weapon varchar(255)
)

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')

Create View

-- Create view called elves containing
CREATE VIEW elves AS (
                        -- Select all rows from adventurers table
                        SELECT * FROM adventurers
                        -- Where the race is elf
                        WHERE race = 'Elf'
                      )

Retrieve View

-- Retrieve all rows from the view Elf
SELECT * FROM elves
nameageraceweapon
Piperel Ramsay35ElfBow
Casimir Yardley14ElfBow