Yassine
Yassine

Reputation: 189

Verify if an index exists in a Sqlite table

I want to verify if an index exists for a SQL table. I'm trying this command (from here) :

SELECT * 
FROM sys.indexes 
WHERE name='YourIndexName' AND object_id = OBJECT_ID('Schema.YourTableName')

But I'm getting the error :

OperationalError: no such table: sys.indexes

with sqlite3 in Python.

Upvotes: 0

Views: 2148

Answers (1)

YJR
YJR

Reputation: 1202

SELECT
   *
FROM
   sqlite_master
WHERE
   type= 'index' and tbl_name = 'your_table_name' and name = 'your_index_name';

You can use above query to verify index exist for a specific table and specific name.

Upvotes: 5

Related Questions