MySQL to PostgreSQL table create conversion - charset and collation

耗尽温柔 提交于 2019-12-07 15:21:27

That one would mean that the table uses only latin-1 (iso-8859-1) character set and latin-1 binary sorting order. In PostgreSQL the character set is database-wide, there is no option to set it on table level.

You could create a mostly compatible database with:

 CREATE DATABASE databasenamegoeshere WITH ENCODING 'LATIN1' LC_COLLATE='C'
     LC_CTYPE='C' TEMPLATE=template0;

However, I personally would consider a MySQL->PostgreSQL port also worthy of switching to UTF-8/Unicode.

The character set is defined when you create the database, you can't overwrite that per table in Postgres.

A non-standard collation can be defined only on column level in Postgres, not on table level. I think(!) that the equivalent to latin1_bin in MySQL would be the "C" collation in Postgres.

So if you do need a different collation, you need something like this

RegEx varchar(300) default NULL collate "C",  
ErrStr varchar(300) default NULL collate "C",

min and max are reserved wordds in SQL and you shouldn't use them as column names (although using them as column names will work I strongly suggest you find different names to avoid problems in the future)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!