Add Data to a Database Table
Add Data to a Database Table
DatabaseLink allows you to interface with databases. Here, SQLInsert is used to put data in a database table.
If you find that these examples do not work as shown, you may need to install or restore the example database with the DatabaseLink`DatabaseExamples` package, as described in "Using the Example Databases".
After loading DatabaseLink and opening a connection, create a table and insert one row of data in it:
Needs["DatabaseLink`"]conn = OpenSQLConnection[ "demo"];SQLCreateTable[conn, SQLTable["TEST"], {SQLColumn["COL1", "DataTypeName" -> "INTEGER"], SQLColumn["COL2", "DataTypeName" -> "DOUBLE"]}];SQLInsert[conn, "TEST", {"COL1", "COL2"}, {10, 10.5}]SQLSelect[conn, "TEST"]SQLInsert[conn, "TEST", {"COL1", "COL2"}, {{10, 10.5}, {20, 55.1}}]SQLSelect[conn, "TEST"]