#!/bin/bash DB=your_sqlite.db TABLE="some_table" INDEXES="$(echo "SELECT name FROM sqlite_master WHERE type == 'index' AND tbl_name = '$TABLE;" | sqlite3 $DB)" for i in $INDEXES; do echo "DROP INDEX '$i';" | sqlite3 $DB done
Make sure that no other process is accessing the database while you are calling this script, or if this is not possible, add
PRAGMA busy_timeout=20000;
in every echo you send to the database
source share