Frage

One of my colleague says Length() function in mysql is not replication safe. This function is used in update statement. Is this true? What else should we take in to consideration when writing a query and taking replication into account

War es hilfreich?

Lösung

Because the table you are replicating too could have a different character set. There is no requirement for tables between master and slave to be exactly the same, have the same indexes etc.

mysql> create table replic(
field1 varchar(20) character set latin1,
field2 varchar(20) character set utf16,
field3 varchar(20) character set utf32);
Query OK, 0 rows affected (0.07 sec)

mysql> insert into replic values('Adrian', 'Adrian', 'Adrian');
Query OK, 1 row affected (0.07 sec)

mysql> select length(field1), length(field2), length(field3) from replic;
+----------------+----------------+----------------+
| length(field1) | length(field2) | length(field3) |
+----------------+----------------+----------------+
|              6 |             12 |             24 |
+----------------+----------------+----------------+
1 row in set (0.00 sec)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top