In practical applications, we often need to import data in Excel into databases such as ms SQL Server or MySQL oracle. These databases provide good tools for users to directly import data in Excel into the database.
Fx6 \ HS) ik C. ug0YoushangCommunityD * Q} 3N U: W "GBJ
However, in many cases, we cannot directly operate databases.Management(Because the security needs to configure the firewall to intercept the database port), we can only remotely operate the database through the web page. In this case, convert the data in Excel to SQLInsert statementIt is very necessary.Youshang community n) J' @ "ei8 _ p
Youshang community b2p u! J? QF
Example:
Jc3tm7ef (B0
? 5_@ 3ksp 'J] 9m0The Excel table contains three columns of data: A, B, and C. You want to import the data to the database users table. The corresponding fields are name, sex, and age.
-K @ A * MCB @ 9e0Youshang community re ^ yd5b y'e; I [* z3t
Add a column to your Excel table and use the Excel Formula to automatically generate SQL statements. The method is as follows:
R4m} 0 \ _ te-| 6 h @ 0
@ Qk9dm3h01. Add a column (column D)Youshang community 5R (nw0h * nwomdk ^
Youshang community Z % L} $ Y & n1h \ f
2. In column D of the first row, enter the formula = concatenate ("insert into users (name, sex, age) values ('", A1 ,"', '", B1,"', '", C1 ,"');")Youshang community f z d; AQ _-c {] S
6] | & J fd4gis03. At this time, D1 has generated the following SQL statement: insert into users (name, sex, age) values ('Ls', 'female, '24 ');Youshang community JCA | oi3cb2t
Youshang community e9o 'ui. l, oh "V
4. Copy the D1 formula to column D of all rowsYoushang community lk1zqe $ ~ G J
3d & Q | kV; bd05. All SQL statements have been generated in column D.
8u5r /~ Gzj & j3P-p0WMB * C V' K/j9a?
6. Copy column D to a plain text file.