Skip to content

📮 Thêm mã bưu chính (Postal Code) cho dataset

Choose a tag to compare

@thanglequoc thanglequoc released this 31 Aug 16:47
· 61 commits to master since this release
b092d6b

Bản release v5.0.0 bổ sung mã bưu chính cho toàn bộ bộ dữ liệu (provinces và wards) ở tất cả các định dạng, đồng thời sửa mã đơn vị hành chính của xã Ba Chẽ theo nguồn dữ liệu DVHCVN chính thức.

📮 Mã bưu chính quốc gia (Mới)

Đây là tính năng chính của bản release v5.0.0. Bộ dữ liệu hiện bao gồm mã bưu chính quốc gia của Việt Nam cho tất cả 34 tỉnh/thành phố và 3.321 xã/phường/thị trấn, giúp các ứng dụng bưu chính, địa chỉ, thương mại điện tử và vận chuyển định tuyến, xác thực và chuẩn hóa địa chỉ chính xác hơn.

Nguồn dữ liệu

Mã bưu chính được lấy từ Quyết định số 2334/QĐ-BKHCN (2025) của Bộ Khoa học và Công nghệ về việc sửa đổi Mã bưu chính quốc gia cho đối tượng là phường, xã:

Quyết định 2334/QĐ-BKHCN 2025 — Sửa đổi Mã bưu chính quốc gia cho đối tượng là phường, xã

Thay đổi cấu trúc (schema)

Hai cột mới được thêm vào các bảng provinces và wards, đồng thời cập nhật trong tệp schema *_CreateTables_* trên cả 4 nền cơ sở dữ liệu quan hệ:

Bảng Cột mới Kiểu dữ liệu Mô tả
provinces postal_code_prefix varchar(255) / nvarchar(255) Danh sách tiền tố mã bưu chính 2 chữ số của tỉnh, phân tách bằng dấu phẩy (một tỉnh có thể có một hoặc nhiều tiền tố)
wards postal_code varchar(20) / nvarchar(20) Mã bưu chính quốc gia 5 chữ số của từng xã/phường/thị trấn

Tệp schema được cập nhật cho từng định dạng:

Định dạng Tệp schema
PostgreSQL postgresql/postgres_CreateTables_vn_units.sql
MySQL / MariaDB mysql/mysql_CreateTables_vn_units.sql
Microsoft SQL Server sqlserver/mssql_CreateTables_vn_units.sql
Oracle oracle/oracle_CreateTables_vn_units.sql

Ví dụ dữ liệu

Mã bưu chính quốc gia Việt Nam gồm 5 chữ số; cột postal_code_prefix chứa (các) tiền tố 2 chữ số đầu được dùng để hình thành mã bưu chính đầy đủ của các xã/phường thuộc tỉnh đó:

Tỉnh postal_code_prefix
Hà Nội 10, 11, 12, 13, 14
Hồ Chí Minh 70, 71, 72, 73, 74, 75, 78
Quảng Ninh 01, 02
Xã/Phường postal_code
Phường Ba Đình, Hà Nội 11120
Phường Hoàn Kiếm, Hà Nội 11024

Dữ liệu trên tất cả các định dạng

Dữ liệu mã bưu chính được điền đầy đủ (34 tỉnh, 3.321 xã/phường) và xuất ra trên tất cả các định dạng của bộ dữ liệu:

Định dạng Tệp dữ liệu
PostgreSQL postgresql/postgres_ImportData_vn_units.sql
MySQL / MariaDB mysql/mysql_ImportData_vn_units.sql
Microsoft SQL Server sqlserver/mssql_ImportData_vn_units.sql
Oracle oracle/oracle_ImportData_vn_units.sql
MongoDB mongodb/mongo_data_vn_unit.json
Redis redis/redis_vn_provinces_dataset.redis
Elasticsearch elasticsearch/provinces.ndjson
JSON json/full_json_generated_data_vn_units.json

📖 Hướng dẫn cài đặt và sử dụng theo từng định dạng xem tại README tương ứng (postgresql/, mysql/, sqlserver/, oracle/, mongodb/, redis/, elasticsearch/, json/).


🏝️ Sửa mã xã Ba Chẽ (Sửa lỗi)

Sửa mã đơn vị hành chính của Xã Ba Chẽ, huyện Ba Chẽ, tỉnh Quảng Ninh theo dữ liệu chuẩn từ nguồn DVHCVN chính thức:

Thông tin Giá trị
Tỉnh Quảng Ninh
Huyện Ba Chẽ
Xã Ba Chẽ
Mã cũ 06978
Mã mới 06970

Dữ liệu được tạo lại trên tất cả các định dạng (PostgreSQL, MySQL, MSSQL, Oracle, MongoDB, Redis, Elasticsearch, JSON, GeoJSON), bao gồm tệp GeoJSON mới json/geojson/22_quang_ninh/wards/06970_ba_che.geojson. Không có thêm / xóa / thay đổi bản ghi nào khác.

Người dùng nâng cấp từ v4.2.0 (hoặc cũ hơn): chạy tệp patch patch/v5.0.0/v5.0.0_patch.sql để sửa mã xã Ba Chẽ trên cơ sở dữ liệu hiện có.

Trân trọng cảm ơn bạn @linkthai đã hỗ trợ đối chiếu để tác giả có cơ hội kiểm tra lại dữ liệu văn bản chính thức trên trang Chính phủ


English version:

This v5.0.0 release adds Vietnamese postal codes for provinces and wards across the entire dataset in all formats, and corrects the administrative code of Ba Chẽ ward according to the official DVHCVN data source.

📮 National Postal Codes (New)

This is the headline feature of the v5.0.0 release. The dataset now includes the Vietnamese national postal codes for all 34 provinces/cities and 3,321 wards/communes/towns, enabling postal, address, e-commerce, and shipping applications to route, validate, and normalize addresses more accurately.

Data source

The postal codes follow Decision 2334/QĐ-BKHCN (2025) of the Ministry of Science and Technology amending the national postal codes for communes and wards:

Decision 2334/QĐ-BKHCN 2025 — Amending the national postal codes for communes and wards

Schema changes

Two new columns were added to the provinces and wards tables, and the *_CreateTables_* schema files were updated across all 4 relational database engines:

Table New column Data type Description
provinces postal_code_prefix varchar(255) / nvarchar(255) Comma-separated list of 2-digit postal code prefixes for the province (a province may have one or more prefixes)
wards postal_code varchar(20) / nvarchar(20) 5-digit national postal code of each ward/commune/town

The schema files updated per format:

Format Schema file
PostgreSQL postgresql/postgres_CreateTables_vn_units.sql
MySQL / MariaDB mysql/mysql_CreateTables_vn_units.sql
Microsoft SQL Server sqlserver/mssql_CreateTables_vn_units.sql
Oracle oracle/oracle_CreateTables_vn_units.sql

Data examples

The Vietnamese national postal code consists of 5 digits; the postal_code_prefix column holds the leading 2-digit prefix(es) used to form the full postal codes of the wards/communes within that province:

Province postal_code_prefix
Hà Nội 10, 11, 12, 13, 14
Hồ Chí Minh 70, 71, 72, 73, 74, 75, 78
Quảng Ninh 01, 02
Ward / Commune postal_code
Ba Đình ward, Hà Nội 11120
Hoàn Kiếm ward, Hà Nội 11024

Data across all formats

The postal code data is fully populated (34 provinces, 3,321 wards/communes) and exported across all dataset formats:

Format Data file
PostgreSQL postgresql/postgres_ImportData_vn_units.sql
MySQL / MariaDB mysql/mysql_ImportData_vn_units.sql
Microsoft SQL Server sqlserver/mssql_ImportData_vn_units.sql
Oracle oracle/oracle_ImportData_vn_units.sql
MongoDB mongodb/mongo_data_vn_unit.json
Redis redis/redis_vn_provinces_dataset.redis
Elasticsearch elasticsearch/provinces.ndjson
JSON json/full_json_generated_data_vn_units.json

📖 For format-specific setup and usage instructions, see the corresponding README (postgresql/, mysql/, sqlserver/, oracle/, mongodb/, redis/, elasticsearch/, json/).


🏝️ Ba Chẽ Ward Code Correction (Fix)

Corrected the administrative code of Xã Ba Chẽ, Ba Chẽ district, Quảng Ninh province according to the official DVHCVN data source:

Detail Value
Province Quảng Ninh
District Ba Chẽ
Ward Ba Chẽ
Old code 06978
New code 06970

The dataset was regenerated in all formats (PostgreSQL, MySQL, MSSQL, Oracle, MongoDB, Redis, Elasticsearch, JSON, GeoJSON), including the new GeoJSON file json/geojson/22_quang_ninh/wards/06970_ba_che.geojson. No other records were added, removed, or changed.

Users upgrading from v4.2.0 (or earlier): run the patch file patch/v5.0.0/v5.0.0_patch.sql to correct the Ba Chẽ ward code on an existing database.

Sincere thanks to @linkthai for helping cross-check the data, giving the author an opportunity to re-verify the official textual data published on the Government’s website.

Contributors

@linkthai