Create / Delete SQLite Database Indexes

| | |
'Create Index
Sub CreateIndex(SQL As SQL, TableName As String, IndexName As String, Fields As String, Unique As Boolean)
   Dim query, uni As String
   uni = ""
   If Unique=True Then uni = "UNIQUE"
   query = "CREATE " & uni & " INDEX IF NOT EXISTS " & IndexName & " ON [" & TableName & "] (" & Fields & ")"
   Log("CreateIndex: " & query)
   SQL.ExecNonQuery(query)
End Sub
'Delete Index
Sub DropIndex(SQL As SQL, IndexName As String)
   Dim query As String
   query = "DROP INDEX IF EXISTS " & IndexName
   Log("DropIndex: " & query)
   SQL.ExecNonQuery(query)
End Sub

Source: Billy047 @ http://www.basic4ppc.com/android/forum/threads/dbutils-android-databases-are-now-simple.8475/page-2

Originally Posted on September 27, 2013
Last Updated on December 30, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.