473,378 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Exporting Column Names Questions

I'm exporting MySQL data using a sql script containing::

SELECT * FROM (database name)
INTO OUTFILE (filename)
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';

The file is created successfully but line 1 of the file does not
contain the column names. Is there an option I need to enable in oder
to produce this? Thanks for any assistance offered.
Jul 20 '05 #1
2 3850
b1cq7 wrote:
I'm exporting MySQL data using a sql script containing::
SELECT * FROM (database name)
INTO OUTFILE (filename)
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';
The file is created successfully but line 1 of the file does not
contain the column names. Is there an option I need to enable in oder
to produce this? Thanks for any assistance offered.


I 'm afraid this option doesn't exist.

SELECT does include column names, SELECT INTO OUTFILE doesn't. But you
can use SELECT to store query results in a file as well, something
like:

mysql -e "SELECT * FROM mytable" -u[USER] -h[HOST] -p[PASS] [DBNAME] >
/path/to/outputfile

Hope this helps
Bart
Jul 20 '05 #2
Bart,
Thanks for the suggestion....seems like a resonable compromise.
ba**@nijlen.com (Bart Van der Donck) wrote in message news:<b5**************************@posting.google. com>...
b1cq7 wrote:
I'm exporting MySQL data using a sql script containing::
SELECT * FROM (database name)
INTO OUTFILE (filename)
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';
The file is created successfully but line 1 of the file does not
contain the column names. Is there an option I need to enable in oder
to produce this? Thanks for any assistance offered.


I 'm afraid this option doesn't exist.

SELECT does include column names, SELECT INTO OUTFILE doesn't. But you
can use SELECT to store query results in a file as well, something
like:

mysql -e "SELECT * FROM mytable" -u[USER] -h[HOST] -p[PASS] [DBNAME] >
/path/to/outputfile

Hope this helps
Bart

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: noor | last post by:
Hi I have been working since 2 days to device a method to export sql table into csv format. I have tried using bcp with format option to keep the column names but I'm unable to transfer the file...
1
by: Janne Ruuttunen | last post by:
Hello DB2 people, I'm having problems exporting >= 250000 lobs to IXF files with the LOBSINFILE option, using a legacy DB2 2.1 system on Win NT. If I don't specify a path for the lobs,...
0
by: premmehrotra | last post by:
I am using Microsoft Access 2000 and Oracle 9.2.0.5 on Windows 2000. When I export a table from Access to Oracle using ODBC I get error: ORA 972 identifier too long I think the error is because...
5
by: premmehrotra | last post by:
I am using Microsoft Access 2000 and Oracle 9.2.0.5 on Windows 2000. When I export a table from Access to Oracle using ODBC I get error: ORA 972 identifier too long I think the error is because...
8
by: Alfonso Morra | last post by:
I am familiar with creating lean and mean WIN32 DLLS and exporting C functions via a DEF file (or cconv decorators), but I am wndering how I can export my C++ objects from my DLLs? Ideally, I...
2
by: pmud | last post by:
Hi, I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column in data grid is Edit Column. I want to display all columns in Excel except for the Edit column. The following...
0
by: Tim_k | last post by:
Does anyone have an example of how to export a datagrid to an Excel pivot table? The code below exports the grid contents to Excel using the Response object. I'd like to expand it to show the...
12
by: 2b|!2b==? | last post by:
I want to export my C++ classes in a DLL, using ordinal # - rather than by name. Will anyone care to enumerate through the steps required to do this? I am already failiar with exporting classes...
2
by: myemail.an | last post by:
Hi all, I need to export a table from Ms Sql to Access. However, dts import/ export gives me an error because the field names are too long. Is there a quick way to trim the names of all fields...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.