unbuntu 16.04 安装 postgresql 10

添加postgreql源

$ wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'

安装 postgresql

$ sudo apt-get update
$ sudo apt-get install postgresql postgresql-contrib libpq-dev

添加用户

$ sudo -u postgres createuser --sup...

postgresql修改文本字段为float时出现PG::DatatypeMismatch: ERROR

今天把以前的.net项目转换为rails时,数据庘由sql server换到postgresql,中间有个表中有地图标记x, y默认都是文本的,转换成float时,出现

PG::DatatypeMismatch: ERROR:  column "x" cannot be cast automatically to type float
HINT:  Specify a USING expression to perform the conversion.

谷歌下,找到如下答案

ALTER TABLE thetable ALTER COLUMN colname TYPE float USING (col_name::float);

鲁ICP备13007872号-1