MySQL Forums
Forum List  »  Perl

Re: executing an SQL statement
Posted by: Randy Clamons
Date: April 25, 2007 01:16PM

Lois,

What I found is that SELECT ... INTO OUTFILE filename.txt by default adds a tab between columns. It should still line up, but the columns will be wider than expected. Here's a statement that produced columns from my table:


SELECT
  RPAD(`id` ,20,' '),
  RPAD(`userid` ,20,' '),
  RPAD(`itemid` ,20,' '),
  RPAD(`datetime` ,20,' '),
  RPAD(`time`,20,' ') ,
  RPAD(`maxbid`,20,' '),
  RPAD(`amount` ,20,' '),
  RPAD(`bidnotes`,100,' ')
INTO OUTFILE 'C:\\tmp\\bids.txt'
fields terminated by ''
FROM bids

The delimiter is an empty string. The first five columns are integers, then next 2 are decimal (10,2), the last column is varchar(100). Notice the varchar column is last.

I hope this helps.

Options: ReplyQuote


Subject
Written By
Posted
April 10, 2007 04:15PM
April 11, 2007 10:02AM
April 11, 2007 03:56PM
April 11, 2007 10:08AM
April 13, 2007 12:26PM
April 17, 2007 04:26PM
April 18, 2007 12:30PM
April 18, 2007 04:02PM
April 23, 2007 04:08PM
April 24, 2007 09:20AM
April 24, 2007 11:39AM
April 24, 2007 02:26PM
April 24, 2007 02:20PM
April 24, 2007 02:31PM
April 24, 2007 03:57PM
Re: executing an SQL statement
April 25, 2007 01:16PM
April 25, 2007 11:46PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.