For the following MySQL create database statement, what would be the equivalent in postgresql?:
CREATE DATABASE IF NOT EXISTS `scratch` DEFAULT CHARACTER SET = utf8 DEFAULT COLLATE = utf8_unicode_ci;
I currently have:
CREATE DATABASE "scratch" WITH OWNER "postgres" ENCODING 'UTF8' TABLESPACE "pg_default";
Is that enough or should I be more specific including LOCALE
as well?
To change the character set encoding to UTF-8 for the database itself, type the following command at the mysql> prompt. Replace dbname with the database name: Copy ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci; To exit the mysql program, type \q at the mysql> prompt.
The character set support in PostgreSQL allows you to store text in a variety of character sets (also called encodings), including single-byte character sets such as the ISO 8859 series and multiple-byte character sets such as EUC (Extended Unix Code), UTF-8, and Mule internal code.
MySQL supports multiple Unicode character sets: utf8mb4 : A UTF-8 encoding of the Unicode character set using one to four bytes per character.
Yes, you can be more specific.
For example:
CREATE DATABASE "scratch" WITH OWNER "postgres" ENCODING 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';
Also I recommend to read the following pages about locales and collations in PostgreSQL:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With