Database Download

Postcodes in Malaysia are hardly changed. Therefore, the database is scheduled to update every 6 months by default. Updates may roll out between this period if there are major changes. You can subscribe to our RSS or follow us in Twitter for latest updates. Malaysia postcode database is available in CSV and SQL format.

 

File Name Size Date Downloads  
malaysia_postcode.csv.zip 341.34 kB 12 Mar, 2014 (2 years ago) 4353
malaysia_postcode.sql.zip 360.03 kB 12 Mar, 2014 (2 years ago) 2101

 

 

CSV Format

Comma-separated values (CSV) file gives flexibilities to import postcode data into any kind of database management system (DBMS) such as MySQL, MS SQL, Microsoft Access, Oracle, PostgreSQL, or SQLite. CSV package contains malaysia_postcode.csv and state.csv. The data is semicolon-delimited plain text and encoded in UTF-8 format.

 

malaysia_postcode.csv:
"postcode";"area_name";"post_office";"state_code"
"50450";"Persiaran Lidcol";"Kuala Lumpur";"KUL"
"50450";"Persiaran Stonor";"Kuala Lumpur";"KUL"
"50450";"Rumah Sabah";"Kuala Lumpur";"KUL"
"50450";"Wisma MCA";"Kuala Lumpur";"KUL"
"50460";"Bangunan Perangsang Segemal";"Kuala Lumpur";"KUL"
"50460";"Bukit Petaling";"Kuala Lumpur";"KUL"
"50460";"Desa Angkasaraya PUKL";"Kuala Lumpur";"KUL"
"50460";"Jalan Akar";"Kuala Lumpur";"KUL"
"50460";"Jalan Belfield";"Kuala Lumpur";"KUL"
"50460";"Jalan Bellamy";"Kuala Lumpur";"KUL"
"50460";"Jalan Bukit Petaling";"Kuala Lumpur";"KUL"
"50460";"Jalan Choo Cheng Khay";"Kuala Lumpur";"KUL"
"50460";"Jalan Gajus";"Kuala Lumpur";"KUL"
"50460";"Jalan Hose";"Kuala Lumpur";"KUL"
"50460";"Jalan Istana";"Kuala Lumpur";"KUL"
"50460";"Jalan Kampung Attap";"Kuala Lumpur";"KUL"
"50460";"Jalan Kerayong Kecil";"Kuala Lumpur";"KUL"
"50460";"Jalan Kerayong";"Kuala Lumpur";"KUL"
"50460";"Jalan Lapangan Terbang Lama";"Kuala Lumpur";"KUL"
"50460";"Jalan Manau";"Kuala Lumpur";"KUL"

 

state.csv:
"state_code";"state_name"
"JHR";"Johor"
"KDH";"Kedah"
"KTN";"Kelantan"
"KUL";"Wilayah Persekutuan Kuala Lumpur"
"LBN";"Wilayah Persekutuan Labuan"
"MLK";"Melaka"
"NSN";"Negeri Sembilan"
"PHG";"Pahang"
"PJY";"Wilayah Persekutuan Putra Jaya"
"PLS";"Perlis"
"PNG";"Pulau Pinang"
"PRK";"Perak"
"SBH";"Sabah"
"SGR";"Selangor"
"SRW";"Sarawak"
"TRG";"Terengganu"

 

 

Import CSV into MySQL Database

Use the following MySQL commands to create neccessary tables:

CREATE TABLE `postcode` (
	`postcode` CHAR(5) NOT NULL COLLATE 'utf8_bin',
	`area` VARCHAR(70) NOT NULL COLLATE 'utf8_bin',
	`post_office` VARCHAR(30) NOT NULL COLLATE 'utf8_bin',
	`state_code` CHAR(3) NOT NULL COLLATE 'utf8_bin',
	INDEX `idx_postcode` (`postcode`),
	INDEX `idx_state_code` (`state_code`)
)
COLLATE='utf8_bin' ENGINE=MyISAM;

CREATE TABLE `state` (
	`state_code` CHAR(3) NOT NULL COLLATE 'utf8_bin',
	`state_name` VARCHAR(35) NOT NULL COLLATE 'utf8_bin',
	INDEX `idx_state_code` (`state_code`)
)
COLLATE='utf8_bin' ENGINE=MyISAM;

Then, import the postcode data using statements below:

LOAD DATA LOCAL INFILE 'postcode.csv' INTO TABLE `postcode` FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\n';
LOAD DATA LOCAL INFILE 'state.csv' INTO TABLE `state` FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\n';

 

 

SQL Format

If you are using MySQL database for your applications, import the postcode data using SQL format is the fastest way. After download and decompress the package, execute following command:

mysql -u <username> -p<password> malaysia_postcode < malaysia_postcode.sql

 

 

 

 

Creative Commons License This work is licensed under a Creative Commons Attribution 3.0 Unported License.