SQLExecute
This feature is not supported on the Wolfram Cloud.

SQLExecute[conn,command]
executes a command in an SQL connection.

SQLExecute[conn,command,args]
passes arguments to the command.

SQLExecute[SQLSelect[conn,...]]
manages the opening and closing of conn.

DetailsDetails

  • To use SQLExecute, you first need to load DatabaseLink using Needs["DatabaseLink`"].
  • Use this function with caution, as you can lose data permanently!
  • Options support and behavior varies with driver, driver version, and RDBMS type.
  • Returns an integer specifying the number of rows affected by the query. Returns $Failed if an error is encountered when dropping a table.
  • The following options can be given:
  • "ColumnSymbols"Nonesymbols to be associated with results
    "EscapeProcessing"Truetranslate escaped JDBC function syntax
    "FetchSize"AutomaticJDBC driver hint for filling result sets
    "GetAsStrings"Falsereturn all results as strings
    "GetGeneratedKeys"Falsereturn keys associated with updated records
    "MaxFieldSize"Automaticbyte limit for variable-length column types
    "MaxRows"Automaticthe maximum number of rows to return
    "ShowColumnHeadings"Falsewhether to return headings with the results
    "Timeout"$SQLTimeoutthe timeout for the query
    "BatchSize"1000queries with parameters will be processed incrementally in batches of this size
    "JavaBatching"Trueperform parameter batching in Java layer instead of Wolfram Language layer

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

In[1]:=
Click for copyable input

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 package, as described in Using the Example Databases.

Open a connection:

In[2]:=
Click for copyable input

Select data:

In[3]:=
Click for copyable input
Out[3]=

Create a table:

In[4]:=
Click for copyable input
Out[4]=

Insert data:

In[5]:=
Click for copyable input
Out[5]=
In[6]:=
Click for copyable input
Out[6]=

Select data:

In[7]:=
Click for copyable input
Out[7]=

Update data:

In[8]:=
Click for copyable input
Out[8]=
In[9]:=
Click for copyable input
Out[9]=

Delete data:

In[10]:=
Click for copyable input
Out[10]=

Drop the table:

In[11]:=
Click for copyable input
Out[11]=
In[12]:=
Click for copyable input