A question to the internal #DBA
channel at work: »Is
it possible to change a column type from BIGINT
to
VARCHAR
? Will the numbers be converted into a
string version of the number or will be it a byte-wise transition
that will screw the values?«
Further asking yielded more information: »The use-case is to have strings, to have UUIDs.«
So we have two questions to answer:
- Is
ALTER TABLE t CHANGE COLUMN c
lossy? -
INTEGER AUTO_INCREMENT
vs.UUID
Is ALTER TABLE t CHANGE COLUMN c lossy?
ALTER TABLE
is not lossy. We can test.
mysql> create table kris ( id integer not null primary key auto_increment);
Query OK, 0 rows affected (0.16 sec)
mysql> insert into kris values (NULL);
Query OK, 1 row affected (0.01 sec)
mysql> insert into kris select NULL from kris;
Query OK, 1 …
[Read more]