📘Introducing SQL Notebooks: Tell stories using data.Read more →

How to Drop an Index in Redshift

This article deals with removing primary key, unique keys and foreign key constraints from a table. Please refer to Creating Indexes to understand the different treatment of indexes/constraints in Redshift.

To remove a constraint from a table, use the ALTER TABLE.. DROP CONSTRAINT command:

-- If you don't know the name of the constraint, you can look it up using:
SELECT constraint_name, constraint_type
FROM information_schema.table_constraints
WHERE table_name='your_table_name';

-- Then drop the constraint using the ALTER TABLE command:

Ready for a modern SQL editor?