DO $$BEGIN
-- FK 비활성화
SET session_replication_role = 'replica';
-- 인덱스 비활성화
EXECUTE REPLACE('ALTER TABLE %s DISABLE TRIGGER ALL;', '%s', '_테이블명_');
EXECUTE REPLACE('UPDATE pg_index SET indisready=false WHERE indrelid = ( SELECT oid FROM pg_class WHERE relname=LOWER(''%s''));', '%s', '_테이블명_');
END$$;
DO $$BEGIN
-- 인덱스 재생성
EXECUTE REPLACE('UPDATE pg_index SET indisready=true WHERE indrelid = ( SELECT oid FROM pg_class WHERE relname=LOWER(''%s''));', '%s', '_테이블명_');
EXECUTE REPLACE('ALTER TABLE %s ENABLE TRIGGER ALL;', '%s', '_테이블명_');
EXECUTE REPLACE('REINDEX TABLE %s;', '%s', '_테이블명_');
-- FK 재활성화
SET session_replication_role = 'origin';
END$$;