List Columns In Table

Create Table Of Elves

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

Insert Rows Into Elf Table

INSERT INTO elves (name, age, race, alive)
VALUES ('Dallar Woodfoot', 25, 'Elf', 'Yes'),
       ('Cordin Garner', 29, 'Elf', 'Yes'),
       ('Keat Knigh', 24, 'Elf', 'Yes'),
       ('Colbat Nalor', 124, 'Elf', 'Yes')

View Columns Rows In Elf Table

-- Get name, data ype and column position
SELECT column_name, data_type, ordinal_position
-- From the column's metadata
FROM information_schema.columns
-- Where the table name is elves
WHERE table_name = 'elves'
column_namedata_typeordinal_position
namecharacter varying1
ageinteger2
racecharacter varying3
alivecharacter varying4