DatabaseLink`
DatabaseLink`
SQLDelete
Details and Options
- To use SQLDelete, you first need to load DatabaseLink using Needs["DatabaseLink`"].
- Use this function with caution, as you can lose data permanently!
- Returns an integer specifying the number of rows affected by the query.
- The following option can be given:
-
"Timeout" $SQLTimeout the timeout for the query
Examples
Basic Examples (1)
Needs["DatabaseLink`"]If you find that the examples in this section 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.
conn = OpenSQLConnection["demo"];SQLCreateTable[conn, SQLTable["TEST"], {SQLColumn["COL1", "DataTypeName" -> "INTEGER"], SQLColumn["COL2", "DataTypeName" -> "DOUBLE"]}];SQLInsert[conn, "TEST", {"COL1", "COL2"}, {
{10, 10.5},
{20, 17.5}
}];Delete all the data in a table:
SQLDelete[conn, "TEST"]SQLSelect[conn, "TEST"]Delete data matching a condition:
SQLInsert[conn, "TEST", {"COL1", "COL2"}, {{10, 10.5}, {20, 17.5}}];SQLDelete[conn, "TEST", SQLColumn["COL1"] > 15]SQLSelect[conn, "TEST"]SQLDropTable[conn, "TEST"];CloseSQLConnection[conn];