Skip to content

Instantly share code, notes, and snippets.

@zmack
Created June 10, 2013 15:03
Show Gist options
  • Save zmack/5749432 to your computer and use it in GitHub Desktop.
Save zmack/5749432 to your computer and use it in GitHub Desktop.
Sql
mysql> create table mars( id int unsigned, bar enum('foo','bar','baz'))
mysql> insert into mars values (1,'foo'), (2, 'bar'), (3, 'baz');
mysql> select * from mars;
+------+------+
| id | bar |
+------+------+
| 1 | foo |
| 2 | bar |
| 3 | baz |
+------+------+
3 rows in set (0.00 sec)
mysql> alter table mars change bar bar enum('moo', 'foo', 'bar', 'baz');
mysql> select * from mars;
+------+------+
| id | bar |
+------+------+
| 1 | foo |
| 2 | bar |
| 3 | baz |
+------+------+
3 rows in set (0.00 sec)
mysql> alter table mars change bar bar enum('moo', 'goo', 'bar', 'baz');
Query OK, 3 rows affected, 1 warning (0.36 sec)
Records: 3 Duplicates: 0 Warnings: 1
mysql> select * from mars;
+------+------+
| id | bar |
+------+------+
| 1 | |
| 2 | bar |
| 3 | baz |
+------+------+
3 rows in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment