postgres-SQL学习笔记:如何将DAT文件传输到PG中

本文详细介绍了如何将DAT文件成功导入到空间数据库的过程,并解决了在使用shp2pgsql工具时遇到的字符编码问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天成功实现了将DAT文件拷贝到空间数据库中;


http://gis.stackexchange.com/questions/39238/how-to-import-shp2pgsql


1 Answer
activeoldestvotes
up vote
9
down vote
accepted
Have you tried -W "latin1" flag? Sometimes the default encoding (UTF-8) doesn't work well. Maybe you'll have better luck with latin1 encoding:

shp2pgsql -I -s 4326 -W "latin1" districts.shp districts | psql -d postgres -U postgres
There's a useful cheat-sheet available here.

Hope it helps..

shareimprove this answer
answered Nov 3 '12 at 17:18

Haziq
795519
1
Hmm.. Have you correctly installed the PostGIS extension to the postgres database? If you haven't: maybe this can help.. – Haziq Nov 3 '12 at 17:45

Usually if make install worked, you can move on to next process (make check is a step prior to make install).. If you can connect to your database via psql/pgadmin3 - that means your installation is a success. Can you move on to the "Create a spatial database" step? I recommend using the EXTENSIONS method.. – Haziq Nov 4 '12 at 15:55

Dude, this has strayed too far from your original question, haha.. It's a little hard to help you here when there's are a lot of variables at play: which version of PostgreSQL are you using?; on what kind of system?; and which version of PostGIS are you trying to install? It seems like it didn't recognize the "CREATE EXTENSION" syntax.. Does typing only: psql -d geocoding -U postgres gets you into the geocoding database successfully? – Haziq Nov 4 '12 at 16:50

My bad. Then you should follow the 2.5. Create a spatially-enabled database on PostgreSQL lower than 9.1 section.. If you still run into problems I'd suggest that you open a new question - so you can get better answers ;) – Haziq Nov 4 '12 at 16:56
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值