Search code examples
amazon-redshiftsql-workbench-jsavepoints

How do I use savepoints in SQL Workbench/J with Redshift?


Is it possible to recreate the following in redshift sql workbench?

create table test as 
select top 10 * from core_data;
savepoint sv;
delete from test
where name like 'A%';
savepoint sv2;
delete from test
where name like 'B%';
rollback to sv;

Solution

  • Redshift doesn't support Rollback to Savepoints at all by any means. Hence you can't do with workbench as well.

    See here list of all the unsupported PostgreSQL functions by Redshift. It includes savepoints as well.

    If you execute rollback to savepoint query to Redshift like,

    rollback to savepointexample;
    

    You will see following error.

    ERROR: SQL command "rollback to savepoint sv3;" not supported.