column headings with export table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tembil
    New Member
    • Feb 2008
    • 11

    column headings with export table

    Hi,
    I'm trying to export data from MySQL to a text file or create a dumpfile and now I want to include column headings as well in my query how can this be done using a big file e.g a file containing more than 8 million records.
    Thanx
    Tembi
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Welcome to to TSDN tembil!

    What exactly do you want for output? A text file (CSV format) with the first record containing the table column names? Or a mysql dump with the create table statement?

    Ronald

    Comment

    • tembil
      New Member
      • Feb 2008
      • 11

      #3
      Originally posted by ronverdonk
      Welcome to to TSDN tembil!

      What exactly do you want for output? A text file (CSV format) with the first record containing the table column names? Or a mysql dump with the create table statement?

      Ronald
      Hi Ronald,
      I need a text file that displays all column headings and the data I tried to use a union statement but it doesn't work with bigger files it only works with smaller ones.
      Thanx in advance
      Tembi

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        So it is a CSV file you are looking for? First, open a table, read all the column names and write them as the first record of your text file. Then read all rows of the table, writing a text record to the file for each row.

        Ronald

        Comment

        • tembil
          New Member
          • Feb 2008
          • 11

          #5
          Originally posted by ronverdonk
          So it is a CSV file you are looking for? First, open a table, read all the column names and write them as the first record of your text file. Then read all rows of the table, writing a text record to the file for each row.

          Ronald
          Hi
          I need a text file, here's the code that I used:
          [CODE=mysql](SELECT 'Surname', 'Forename 1', 'Forename 2', 'Forename 3', 'DOB', 'RSA ID', 'Other ID', 'Gender', 'Title', 'Marital Status', 'Spouse Name', 'FirstAddressUp dateDate', 'FirstAddressYe arsOfTenure', 'FirstAddressLi ne1', 'FirstAddressLi ne2', 'FirstAddressLi ne3', 'FirstAddressLi ne4', 'FirstAddressPo stCode', 'FirstAddressPr ovCode', 'FirstAddressCo untryCode', 'FirstAddresOTI nd', 'SecondAddressU pdateDate', 'SecondAddressY earsOfTenure', 'SecondAddressL ine1', 'SecondAddressL ine2', 'SecondAddressL ine3', 'SecondAddressL ine4', 'SecondAddressP ostCode', 'SecondAddressP rovCode', 'SecondAddressC ountryCode', 'SecondAddressO TInd', 'ThirdAddressUp dateDate', 'ThirdAddressYe arsOfTenure', 'ThirdAddressLi ne1', 'ThirdAddressLi ne2', 'ThirdAddressLi ne3', 'ThirdAddressLi ne4', 'ThirdAddressPo stCode', 'ThirdAddressPr ovCode', 'ThirdAddressCo untryCode', 'ThirdAddressOT Ind', 'FourthAddressU pdateDate', 'FourthAddressY earsOfTenure', 'FourthAddressL ine1', 'FourthAddressL ine2', 'FourthAddressL ine3', 'FourthAddressL ine4', 'FourthAddressP ostCode', 'FourthAddressP rovCode', 'FourthAddressC ountryCode', 'FourthAddressO TInd', 'Employer 1', 'Emp 1 Update Date', 'Emp 1 Occupation', 'Employer 2', 'Emp 2 Update Date', 'Emp 2 Occupation', 'Employer 3', 'Emp 3 Update Date', 'Emp 3 Occupation', 'Work Tel 1 Date', 'Work Tel 1 Code', 'Work Tel 1 No', 'Work Tel 2 Date', 'Work Tel 2 Code', 'Work Tel 2 No', 'Work Tel 3 Date', 'Work Tel 3 Code', 'Work Tel 3 No', 'Home Tel 1 Date', 'Home Tel 1 Code', 'Home Tel 1 No', 'Home Tel 2 Date', 'Home Tel 2 Code', 'Home Tel 2 No', 'Home Tel 3 Date', 'Home Tel 3 Code', 'Home Tel 3 No', 'Cell 1 Date', 'Cell 1 No', 'Cell 2 Date', 'Cell 2 No', 'Cell 3 Date', 'Cell 3 No', 'Email Add', 'ID', 'Task_ID', 'File_date')
          UNION
          (Select *
          FROM itc_db.`quintus `
          WHERE LENGTH(`quintus `.`RSA ID`) = 13 AND
          LENGTH(`quintus `.`File_Date`) = 10
          INTO OUTFILE "C:\Dumpfiles\m yfile4.txt"
          FIELDS TERMINATED BY '|'
          LINES TERMINATED BY '\r\n'
          );[/CODE]

          Comment

          Working...