List Index Columns

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

Create Index

-- Index the names column in the elves table
CREATE INDEX ON elves (name)

View All Indexes In Database

SELECT indexes.tablename, indexes.indexname, columns.column_name
FROM pg_catalog.pg_indexes indexes, information_schema.columns columns
WHERE indexes.schemaname = 'public'
AND indexes.tablename  = columns.table_name
tablenameindexnamecolumn_name
elveselves_name_idxname
elveselves_name_idxage
elveselves_name_idxrace
elveselves_name_idxalive