tags:

views:

89

answers:

2

I know how to execute single statements, but is their a way to execute a block of statements in some easy way. I just want to delete a column from a table.

BEGIN TRANSACTION;
CREATE TEMPORARY TABLE t1_backup(a,b);
INSERT INTO t1_backup SELECT a,b FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a,b);
INSERT INTO t1 SELECT a,b FROM t1_backup;
DROP TABLE t1_backup;
COMMIT;
A: 

It looks like you have this solved already. I don't think there's a better solution than what you posted in your question.

Ben S
A: 

Looks like the only way is to execute each line as a separate query and create a transaction. I wish there should be some API to execute a bunch of queries at once.

Priyank Bolia