Put your tips and tricks online - Share your knowledge! Login | Register
 
 
  Search     Advanced search
 

Home | Ask Question | Add tip | Questions | My tips | Recent tips & tricks | Suggest a category | FAQ | Forums

 
 
 
 Category : Home > Databases > MySQL     

How to save query results in a text file


Here's how to put MySQL query results in an ASCII file i.e. tab delimited or CSV file.

mysql> SELECT field1, field2 FROM tab1 INTO OUTFILE 'logfile.txt';

By default fields will be separated by tab, but you can change it using the following
command:

mysql> SELECT field1, field2 FROM tab1
       INTO OUTFILE 'logfile.txt'
       FIELDS TERMINATED BY ',' 
       ENCLOSED BY '"' 
       LINES TERMINATED BY '\n';



  Options
 
   del.icio.us  |  newsvine  |  digg  |  furl  |  google  |  yahoo  |  Ma.gnolia  |  vigillar  |  reddit  |  technorati  |  icerocket  |  pubsub

       Rate this tip:    

Start discussion or add comment to this tip

  Details
Tip reference : #120
views : 531
Added on : 10/19/06
Submited by : ingres
 
Send a message Send a message Printer friendly output Printer friendly output
Display this member's tips Display this member's tips (5)
 
 
<< Previous Next >>
 Most viewed tips 
  Databases > Oracle > Security : How to unlock Oracle user account  
  Databases > Oracle > Performance Tuning : How to enable trace in Oracle  
  Databases > Oracle : Kill user session  
  Operating Systems > Unix : How to kill Unix user session  
   
  All categories
Databases | Programming | Hardware | Operating Systems | Networking | Internet | ERP / CRM | Games & Multimedia | Graphics & Design | Miscellaneous | Office Software | TipLib FAQ
 
 

Home |  FAQ |  Terms of Use |  Privacy Policy

© 2005 tiplib.com