Importing Large XML file into SQL 2.5Gb

前端 未结 3 2023
予麋鹿
予麋鹿 2020-12-22 11:43

Hi I am trying to import a large XML file into a table on my sql server (2014)

I have used the code below for smaller files and thought it would be ok as this is a o

3条回答
  •  萌比男神i
    2020-12-22 12:44

    Updated: Much faster. I did some research, and while the above post I made shows one (slow) method, I was able to find one that works even faster - for me it does. I put this as a new answer due to the complete difference from my previous post.

    LOAD XML LOCAL INFILE 'path/to/file.xml' INTO TABLE tablename ROWS IDENTIFIED BY ''
    

    Example

    
        
           john doe
              bla bla bla......
        
    
    

    Then, MYSQL command would be:

    LOAD XML LOCAL INFILE 'path/to/students.xml' INTO TABLE tablename ROWS IDENTIFIED BY ''
    

    rows identified must have single quote and angle brackets. when I switched to this method, I went from 12min +/- to 30 seconds!! +/-

    tips that worked for me. was use the DELETE FROM tablename otherwise it will just append to your db.

    Ref: https://dev.mysql.com/doc/refman/5.5/en/load-xml.html

提交回复
热议问题