tags:

views:

31

answers:

2

I want to remove a column from a table.

How can I do this?

+2  A: 

As per the documentation, this is not possible without creating a new table. The method involves creating a new table (either temporary or the new table, depending on the complexity of changes), copying the data you need into it, deleting the old table, and remaking the table (if necessary).

Thomas Owens
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;
Jauzsika
@Jauzsika: do **not** put such code blocks into a comment, please. You cannot nicely format it, it is terribly hard to read - if you have a solution, make it an answer where you can easily format your code snippet nicely!
marc_s
+1  A: 

You need simply to copy data you need to another table. Check out an example here: robbiebow

netme