Export table of 50 columns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Export table of 50 columns
# 1  
Old 05-09-2012
Export table of 50 columns

Dear all,

I have a big table of 50 columns and more then 100, 000 rows in mysql. Could you please help me that how I can export it as .csv or . txt that I can open it in MS excel?????
OR how can I export the specific columns of the table???

Thanks

AAWT
# 2  
Old 05-09-2012
One of the first hits when entering "mysql export csv" in Google brought this:
MySQL :: Re: Export to CSV

When importing to Excel, you will have to specify the same file delimeter that you have chosen when exporting.
Additionally it would be good to read up on the SELECT-statement.

Last edited by zaxxon; 05-09-2012 at 09:41 AM..
# 3  
Old 05-09-2012
Code:
mysql -u username -ppassword instancename -e "select id,name from table;" |awk '{print$1","$2}'

The above will export those two columns from that table and then put a comma between each one. You can modify it to fit your column names or you can do a
Code:
select *

This User Gave Thanks to brianjb For This Post:
# 4  
Old 05-10-2012
Smilie oh I am getting the problem with these
from google link,,,,,,

after opening in excel one row is coming in two rows,,,,,,,means last three columns data is in 2nd row,

and Brianjb,,,,
I modify and use select * and it export only 2 columns,,,,then I add the $1----$26 and I got the error
Code:
awk: {print$1","$2,"$3,"$4,"$5,"$6,"$7, "$8, "$9,"$10,"11$,"$12,"$13,"$14,"$15,"$16,"$17, "$18$,"$19,"$20,"$21,"$22,"$23,"$24,"$25,"$26}
awk:                                                                                           ^ syntax error

So,,,,,looking for help
# 5  
Old 05-10-2012
Add this to the end:

Code:
awk '{print$1","$2","$3","$4","$5","$6","$7","$8","$9","$10","$11","$12","$13","$14","$15","$16","$17","$18$","$19","$20","$21","$22","$23","$24","$25","$26}'

Notice that there are double quotes around each comma. That is telling awk to print what is in the double quotes. Then the $ means to print that number of field.

---------- Post updated at 07:37 AM ---------- Previous update was at 07:34 AM ----------

aawt,

If you do this:

Code:
I modify and use select * and it export only 2 columns

That should export every column in that table.

Do this command:

Code:
mysql -u username -ppassword instancename -e "show columns from tablename"

where the tablename is the name of the table that you only got two columns exported. It is possible that you are trying to export the wrong table.
This User Gave Thanks to brianjb For This Post:
# 6  
Old 05-10-2012
I'm not sure about the switch for CSV, but it was there and most probably it is still there to export in CSV format...no need to do a piped processing..

---------- Post updated at 07:24 PM ---------- Previous update was at 07:21 PM ----------

Code:
SELECT *
INTO OUTFILE '/tmp/products.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM products


for your reference... please use
Export data to CSV from MySQL
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Export HTML table

HI , I have a HTML tables as below. It has 2 tables ,I want to extract the second table . Please help me in doing it. <html> <body> <b><br>Running Date: </b>11-JAN-2019 03:07</br> <h2> Schema mapping and info </h2> <BR><TABLE width="100%" class="x1h" cellpadding="1"... (3 Replies)
Discussion started by: deepti01
3 Replies

2. UNIX for Advanced & Expert Users

How can i export entries from table into a variable and parse them?

Hi, I need to export some entries from a table, from a specific column and then redirect them into a file. I used sql plus, in order to fetch the entries and i put them in one variable. When i am running the script it stuck at a point and does not move further. I did something like: ... (4 Replies)
Discussion started by: cookie2
4 Replies

3. Shell Programming and Scripting

How to export hive table data to a file on local UNIX?

Hi All , I am stuck on the below situation.I have a table called "test" which are created on hive.I need to export the data from hive to a file(test.txt) on local unix system.I have tried the below command ,but its giving the exception . hive -e "select * from test " > /home/user/test.txt ; ... (1 Reply)
Discussion started by: STCET22
1 Replies

4. Shell Programming and Scripting

Export table and restart from last table

Hello all, Thank you in advance for reading my post and helping me.. Scenario: I have 50 tables whose names are in a file export.sql, i use the below command to export all these tables one by one cat export.sql|while read tn do echo "export to $tn.del of del select from... (7 Replies)
Discussion started by: family_guy
7 Replies

5. Shell Programming and Scripting

Shell script to export data from Oracle table .

Hi, I want to write a shell script which will export data from oracle table . I don't want to save that data . I want the queries . Right now i am right clicking on the table and clicking on export as to my desktop . Please let me know if any one have any idea . (2 Replies)
Discussion started by: honey26
2 Replies

6. Shell Programming and Scripting

How to export table data to xml file?

Hi , I would like to get some suggestion from the experts. My requirement is to export oracle table data as an xml file. Any unix/linux tools, scripts available? Regards, (2 Replies)
Discussion started by: LinuxLearner
2 Replies

7. Shell Programming and Scripting

Problem in scheduling an Export of a table

Hi, I am facing a problem while scheduling an export of a table using cron job. I have written a simple export command inside a shell script test.sh like echo started exp schemaname/temp1234 file= /test/d.dmp tables=per_st log= /test/d.log echo ended I tried scheduling it through... (6 Replies)
Discussion started by: beautifulmind
6 Replies

8. Shell Programming and Scripting

Export a HTML table to Xcel

Hello All, I have a perl script that prints a HMTL table. I want to convert this data into a report and this want to export this information into Excel. How can I do this? Regards, garric (3 Replies)
Discussion started by: garric
3 Replies

9. Shell Programming and Scripting

help for writing shell script to export table data

Hi All, I need to write a shell script(ksh) to take the tables backup in oracle(exporting tables data). The tables list is not static, and those are selecting through dynamic sql query. Can any body help how to write this shell script. Thanks, (3 Replies)
Discussion started by: sankarg
3 Replies

10. Shell Programming and Scripting

export table from oracle database

i would like to export a particular table in my oracle database installed in a hpux box. i would like to determine the filesize of the output before performing these action so i can assess if my harddisk can still handle it. thanks as usuall :rolleyes: (1 Reply)
Discussion started by: inquirer
1 Replies
Login or Register to Ask a Question