1.excel文件处理
2.文件格式处理Notepad ++
1).文件转换为UNIX格式
2).格式转换为UTF8无BOM
注意事项:
1).字符集配置,操作系统字符集LANG=en_US.UTF-8
数据库字符集UTF-8
uccc_im=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
import_testdb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(5 rows)
import_testdb=#
import_testdb=# show server_encoding ;
server_encoding
-----------------
UTF8
(1 row)
import_testdb=# show client_encoding ;
client_encoding
-----------------
UTF8
(1 row)
import_testdb=#
2).CSV导入数据库
import_testdb=#
import_testdb=# COPY zh_tbl FROM '/var/lib/pgsql/zh_data_2016.01.21.csv' DELIMITER ',';