Which encoding to choose for a database?


When we create a new base (regardless of whether it is in MySQL, PostgreSQL, Oracle, SQLServer or other) we can choose which encoding from that database, such as UTF- strong> or Latin-1 .

  • Is there a recommendation or does this make no difference?

  • In the case of encodings where a character can occupy more than one byte, such as UTF-8, if I define a column as% , can I save 5 special characters (example: varchar(5) )?

  • The MySQL Workbench wizard offers different variations of some encodings like Latin-1 and UTF-8 . What's the difference between these variations?


    asked by anonymous 12.06.2014 / 20:50

    1 answer


    Choosing the charset of your database will depend on the application that will use the same.

    UTF-8 is a standard that supports in addition to Latin characters, Greek characters, Hebrew, among others, thus being a chartset that supports multiple languages.

  • If your application needs to be multilingual, using UTF-8 ensures that characters display correctly to users no matter what language they use. Several open source projects ( Wordpress , Drupal ,

  • In MySQL a varchar(5) stores up to five characters, regardless of the size in . For international characters, SQL Server assumes a different field type for data: nchar e nvarchar . For these data types strings should be delimited with N''

  • The different collations are used in the way that sorting and comparison will be executed and may vary according to the region alphabetical considering accents for example). The _ci represents whether Collation is Case Insensitive (case sensitive) in the Comparison . More details of the implementation in MySQL can be found here .

  • 13.06.2014 / 21:08