Generated from excel Batch SQL table, entering data into the database generated from excel Batch SQL table, entering data into the database

https://www.cnblogs.com/dingxu/p/9151810.html

 

Excel Batch SQL generated from the table, entering data into the database

There are many excel spreadsheet data, it is necessary to import data into the database, a hand can not enter a can generate the SQL, to batch operations.
 

 

 
1. In the first column of the second row of the H, the insertion function: = CONCATENATE ( "INSERT INTO` book` ( `bookid`,` title`, `volume`,` author`, `urlpdf`) VALUES ( '", A2 , " ','", B2, " ',' 3 ','", C2, " ','", F2, " ');"), taken on behalf of the data from each column into the function.
 

 

2. In the top left write H2: H100, represents H column, lines 2 to function automatically generated from the line 100, pressing Ctrl + Enter, select the specified column:
 

 

3 to move the cursor to the end of the above functions fx, press Ctrl + Enter, generate SQL statements:
 

 

In the last label at the "H" H top of the column, right-click Copy, successfully copy all the SQL statement, and then execute SQL statements in the database is OK, success will excel spreadsheet data entry into the database.
There are many excel spreadsheet data, it is necessary to import data into the database, a hand can not enter a can generate the SQL, to batch operations.
 

 

 
1.首先在第二行的H列,插入函数:=CONCATENATE("INSERT INTO `book` (`bookid`, `title`,  `volume`, `author`, `urlpdf` ) VALUES ('",A2,"', '",B2,"', '3', '",C2,"', '",F2,"');"),代表从各个列中取数据到函数中。
 

 

2.在左上方写入H2:H100,表示在H列,从函数自动生成2行到100行,按下Ctrl+Enter,选中指定列:
 

 

3.再将光标移到到上方 fx函数末尾,按下Ctrl+Enter,生成SQL语句:
 

 

最后在H列最上方的“H”标号处,右键点击复制,就成功复制了全部SQL语句,然后将SQL语句在数据库中执行就OK了,成功将excel表格中数据录入到数据库中。

Guess you like

Origin www.cnblogs.com/lvgg/p/12035293.html