browser icon
You are using an insecure version of your web browser. Please update your browser!
Using an outdated browser makes your computer unsafe. For a safer, faster, more enjoyable user experience, please update your browser today or try a newer browser.

Exporting Data with the SELECT … INTO OUTFILE Statement

Posted by on December 29, 2010

Berikut syntax untuk membatu dalam melakukan dump database, tetapi kita dapat menentukan field-filed yg kita butuhkan, dengan menggunakan SELECT dengan INTO OUTFILE output_file.

Ikuti langkah berikut ini untuk mengexport table data_tbl ke dalam file data.txt.

mysql> SELECT * FROM data_tbl
-> INTO OUTFILE ‘/tmp/data.txt’;

Output dari perintah diatas akan membuat file /tmp/data.txt. Jika ingin outpunya dalam bentuk CSV (Comma Separate Vallues) bisa mengikuti langkah berikut.

mysql> SELECT * FROM passwd INTO OUTFILE ‘/tmp/contoh.csv’
-> FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘
-> LINES TERMINATED BY ‘rn’;

Dengan query diatas akan menghasilkan file csv dan langsung bisa dibuka menggukan OpenOffice atau MS Excel.

Comments

comments

Leave a Reply

Your email address will not be published. Required fields are marked *

:)) :) :D (LOL) :-P (woot) ;-) :-o X-( ;-( :-& (angry) (annoyed) (bye) B-) (cozy) (sick) (: (goodluck) (griltongue) (mmm) (hungry) (music) (tears) (tongue) (unsure) (highfive) (dance) (doh) (brokenheart) (drinking) (girlkiss) (rofl) (money) (rock) (nottalking) (party) (sleeping) (thinking) (bringit) (worship) (applause) 8-) (gym) (heart) (devil) (lmao) (banana_cool) (banana_rock) (evil_grin) (headspin) (heart_beat) (ninja) (haha) (evilsmirk) (bigeyes) (funkydance) (idiot) (lonely) (scenic) (hassle) (panic) (okok) (yahoo) (blush) (fish_hit) (muhaha) (muscle) (taser) (beer) (coffee) (banana_ninja) (goal) (fireworks) (smileydance) (dance_bzz) (rusian)