PostgreSQL Excel contains Chinese characters in the data import method

Source: Internet
Author: User
Tags postgresql import database

1.excel file Processing

Delete header row, save as comma delimiter csv file


2. file format processing Notepad + +

1). convert Files to UNIX format

2). format conversion to UTF8 no BOM


3. Uploading to the database import

Precautions:

1). Character set configuration, operating system character set Lang=en_us. UTF-8

Database Character Set 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 Database


Import_testdb =#

Import_testdb =# COPY zh_tbl from '/var/lib/pgsql/zh_data_2016.01.21.csv ' DELIMITER ', ';


3) Client Chinese display

SCRT client Character Set default modified to UTF8, solve Chinese characters garbled problem

Pgadmin client direct query without garbled display.


This article is from the "Yiyi" blog, make sure to keep this source http://heyiyi.blog.51cto.com/205455/1904281

PostgreSQL Excel contains Chinese characters in the data import method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.