Skip to content

Instantly share code, notes, and snippets.

@red-led
red-led / copyTableIndexes.sql
Last active August 29, 2015 14:18
Postgres function for table indexes and privileges copying
CREATE OR REPLACE FUNCTION
copyTableIndexes(fromSchema varchar, fromTable varchar, toSchema varchar, toTable varchar)
RETURNS void AS $$
DECLARE
oneIndex record;
q text;
BEGIN
IF
NOT EXISTS(
SELECT *