![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Some of the tables in my database have different character sets and/or collation. The database is working fine but I am worried about some subtle problems occurring. I tried: ALTER DATABASE mydb CHARACTER SET latin1 COLLATE latin1_swedish_ci; as this, according to the docs, is the default character set and collation. After doing this I noticed that the change was not applied to all my tables. I checked this by importing the model into MySQL Workbench. Any comments about this would be appreciated. |
#3
| |||
| |||
|
|
On 6/9/2011 9:00 PM, Joe Hesse wrote: Some of the tables in my database have different character sets and/or collation. The database is working fine but I am worried about some subtle problems occurring. I tried: ALTER DATABASE mydb CHARACTER SET latin1 COLLATE latin1_swedish_ci; as this, according to the docs, is the default character set and collation. After doing this I noticed that the change was not applied to all my tables. I checked this by importing the model into MySQL Workbench. Any comments about this would be appreciated. All that does is set the default collation and charset for the database. These are used when new tables are created without their own charset and/or collation. See http://dev.mysql.com/doc/refman/5.5/...-database.html If you want to change the charset and collation in a table, you must change it for each column in the table. See http://dev.mysql.com/doc/refman/5.5/...et-column.html |
#4
| |||
| |||
|
|
On Thu, 09 Jun 2011 21:20:43 -0400, Jerry Stuckle wrote: On 6/9/2011 9:00 PM, Joe Hesse wrote: Some of the tables in my database have different character sets and/or collation. The database is working fine but I am worried about some subtle problems occurring. I tried: ALTER DATABASE mydb CHARACTER SET latin1 COLLATE latin1_swedish_ci; as this, according to the docs, is the default character set and collation. After doing this I noticed that the change was not applied to all my tables. I checked this by importing the model into MySQL Workbench. Any comments about this would be appreciated. All that does is set the default collation and charset for the database. These are used when new tables are created without their own charset and/or collation. See http://dev.mysql.com/doc/refman/5.5/...-database.html If you want to change the charset and collation in a table, you must change it for each column in the table. See http://dev.mysql.com/doc/refman/5.5/...et-column.html I was thinking that I could change every table in my database to the desired charset and collation by creating a dump file and then edit the CREATE TABLE statements, after the column list. The editing could be done with sed. It seems to me that this would change the charset and collation for every table without dealing with individual columns. I am still new to MySQL and am nervous about subtle problems. Thank you, Joe |
#5
| |||
| |||
|
|
Some of the tables in my database have different character sets and/or collation. The database is working fine but I am worried about some subtle problems occurring. |
|
ALTER DATABASE mydb CHARACTER SET latin1 COLLATE latin1_swedish_ci; as this, according to the docs, is the default character set and collation. After doing this I noticed that the change was not applied to all my tables. |
#6
| |||
| |||
|
|
On 6/9/2011 10:43 PM, Joe Hesse wrote: On Thu, 09 Jun 2011 21:20:43 -0400, Jerry Stuckle wrote: On 6/9/2011 9:00 PM, Joe Hesse wrote: Some of the tables in my database have different character sets and/or collation. The database is working fine but I am worried about some subtle problems occurring. I tried: ALTER DATABASE mydb CHARACTER SET latin1 COLLATE latin1_swedish_ci; as this, according to the docs, is the default character set and collation. After doing this I noticed that the change was not applied to all my tables. I checked this by importing the model into MySQL Workbench. Any comments about this would be appreciated. All that does is set the default collation and charset for the database. These are used when new tables are created without their own charset and/or collation. See http://dev.mysql.com/doc/refman/5.5/...-database.html If you want to change the charset and collation in a table, you must change it for each column in the table. See http://dev.mysql.com/doc/refman/5.5/...et-column.html I was thinking that I could change every table in my database to the desired charset and collation by creating a dump file and then edit the CREATE TABLE statements, after the column list. The editing could be done with sed. It seems to me that this would change the charset and collation for every table without dealing with individual columns. I am still new to MySQL and am nervous about subtle problems. Thank you, Joe Yes, you could do that. However, make a copy of your dump before doing it. I don't like doing it that way unless necessary, though. You can run into all kinds of problems, like foreign key constraints not being met, etc. It often matters what order you restore the database, and it's generally not the order it was dumped. |
#7
| |||
| |||
|
|
On Thu, 09 Jun 2011 22:46:33 -0400, Jerry Stuckle wrote: On 6/9/2011 10:43 PM, Joe Hesse wrote: On Thu, 09 Jun 2011 21:20:43 -0400, Jerry Stuckle wrote: On 6/9/2011 9:00 PM, Joe Hesse wrote: Some of the tables in my database have different character sets and/or collation. The database is working fine but I am worried about some subtle problems occurring. I tried: ALTER DATABASE mydb CHARACTER SET latin1 COLLATE latin1_swedish_ci; as this, according to the docs, is the default character set and collation. After doing this I noticed that the change was not applied to all my tables. I checked this by importing the model into MySQL Workbench. Any comments about this would be appreciated. All that does is set the default collation and charset for the database. These are used when new tables are created without their own charset and/or collation. See http://dev.mysql.com/doc/refman/5.5/...-database.html If you want to change the charset and collation in a table, you must change it for each column in the table. See http://dev.mysql.com/doc/refman/5.5/...et-column.html I was thinking that I could change every table in my database to the desired charset and collation by creating a dump file and then edit the CREATE TABLE statements, after the column list. The editing could be done with sed. It seems to me that this would change the charset and collation for every table without dealing with individual columns. I am still new to MySQL and am nervous about subtle problems. Thank you, Joe Yes, you could do that. However, make a copy of your dump before doing it. I don't like doing it that way unless necessary, though. You can run into all kinds of problems, like foreign key constraints not being met, etc. It often matters what order you restore the database, and it's generally not the order it was dumped. I have read the fine documentation on character sets and collation. It seems theoretical and I'm still not sure if I will wreck something. All the characters in my tables are, for want of a better term, "American", no foreign characters. There are a foreign keys but they are INT. I plan on doing, with backups of course: ALTER TABLE MyTable CHARACTER SET=utf8, COLLATE=utf8_swedish_ci ; for each of the tables in my database. From what I have read, "CHARACTER SET = utf8 , COLLATE =utf8_swedish_ci" is the best choice. If you see a potential problem in what I am doing, please let me know. Thank you everyone for sharing your technical knowledge. That should work, as long as you're actually using an "American" charset. |
#8
| |||
| |||
|
|
All the characters in my tables are, for want of a better term, "American", no foreign characters. |
|
I plan on doing, with backups of course: ALTER TABLE MyTable CHARACTER SET=utf8, COLLATE=utf8_swedish_ci ; |
|
for each of the tables in my database. From what I have read, "CHARACTER SET = utf8 , COLLATE =utf8_swedish_ci" is the best choice. |
![]() |
| Thread Tools | |
| Display Modes | |
| |