Rename Columns In Views

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 with the column's renamed:
-- elven_name, elven_age, race, and elven_weapon
CREATE VIEW elves (elven_name, elven_age, race, elven_weapon) 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
Piperel Ramsay35ElfBow
Casimir Yardley14ElfBow