Share via


SQLiteDatabase.ExecSQL Method

Definition

Overloads

ExecSQL(String, Object[])

Execute a single SQL statement that is NOT a SELECT/INSERT/UPDATE/DELETE.

ExecSQL(String)

Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data.

ExecSQL(String, Object[])

Execute a single SQL statement that is NOT a SELECT/INSERT/UPDATE/DELETE.

[Android.Runtime.Register("execSQL", "(Ljava/lang/String;[Ljava/lang/Object;)V", "GetExecSQL_Ljava_lang_String_arrayLjava_lang_Object_Handler")]
public virtual void ExecSQL (string? sql, Java.Lang.Object[]? bindArgs);
[<Android.Runtime.Register("execSQL", "(Ljava/lang/String;[Ljava/lang/Object;)V", "GetExecSQL_Ljava_lang_String_arrayLjava_lang_Object_Handler")>]
abstract member ExecSQL : string * Java.Lang.Object[] -> unit
override this.ExecSQL : string * Java.Lang.Object[] -> unit

Parameters

sql
String

the SQL statement to be executed. Multiple statements separated by semicolons are not supported.

bindArgs
Object[]

only byte[], String, Long and Double are supported in bindArgs.

Attributes

Exceptions

if the SQL string is invalid

Remarks

Execute a single SQL statement that is NOT a SELECT/INSERT/UPDATE/DELETE.

For INSERT statements, use any of the following instead. <ul> <li>#insert(String, String, ContentValues)</li> <li>#insertOrThrow(String, String, ContentValues)</li> <li>#insertWithOnConflict(String, String, ContentValues, int)</li> </ul>

For UPDATE statements, use any of the following instead. <ul> <li>#update(String, ContentValues, String, String[])</li> <li>#updateWithOnConflict(String, ContentValues, String, String[], int)</li> </ul>

For DELETE statements, use any of the following instead. <ul> <li>#delete(String, String, String[])</li> </ul>

For example, the following are good candidates for using this method: <ul> <li>ALTER TABLE</li> <li>CREATE or DROP table / trigger / view / index / virtual table</li> <li>REINDEX</li> <li>RELEASE</li> <li>SAVEPOINT</li> <li>PRAGMA that returns no data</li> </ul>

When using #enableWriteAheadLogging(), journal_mode is automatically managed by this class. So, do not set journal_mode using "PRAGMA journal_mode'<value>" statement if your app is using #enableWriteAheadLogging()

Note that PRAGMA values which apply on a per-connection basis should <em>not</em> be configured using this method; you should instead use #execPerConnectionSQL to ensure that they are uniformly applied to all current and future connections.

Java documentation for android.database.sqlite.SQLiteDatabase.execSQL(java.lang.String, java.lang.Object[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

ExecSQL(String)

Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data.

[Android.Runtime.Register("execSQL", "(Ljava/lang/String;)V", "GetExecSQL_Ljava_lang_String_Handler")]
public virtual void ExecSQL (string? sql);
[<Android.Runtime.Register("execSQL", "(Ljava/lang/String;)V", "GetExecSQL_Ljava_lang_String_Handler")>]
abstract member ExecSQL : string -> unit
override this.ExecSQL : string -> unit

Parameters

sql
String

the SQL statement to be executed. Multiple statements separated by semicolons are not supported.

Attributes

Exceptions

if the SQL string is invalid

Remarks

Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data.

It has no means to return any data (such as the number of affected rows). Instead, you're encouraged to use #insert(String, String, ContentValues), #update(String, ContentValues, String, String[]), et al, when possible.

When using #enableWriteAheadLogging(), journal_mode is automatically managed by this class. So, do not set journal_mode using "PRAGMA journal_mode'<value>" statement if your app is using #enableWriteAheadLogging()

Note that PRAGMA values which apply on a per-connection basis should <em>not</em> be configured using this method; you should instead use #execPerConnectionSQL to ensure that they are uniformly applied to all current and future connections.

Java documentation for android.database.sqlite.SQLiteDatabase.execSQL(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to