Tuesday, 29 December 2020

How to see the internal content of an index?

When creating an index on a column value:

import sqlite3
db = sqlite3.connect(':memory:')
db.execute("CREATE TABLE data(id INTEGER PRIMARY KEY, value TEXT);")
db.execute("CREATE INDEX data_idx ON data(value);")
for v in ["xyz", "abc", "def", "abc", "ijk"]:
    db.execute("INSERT INTO data(value) VALUES (?)", (v,))

how to display the internal content of the index? For learning purposes, and also in more complex cases, seeing what is stored exactly in the index would be helpful.

As data_idx is not a real table, this fails with no such table: data_idx:

db.execute("SELECT * FROM data_idx")

How to display the internal content of a Sqlite index? (it should be a correspondance between sorted values and rowids I guess?)



from How to see the internal content of an index?

No comments:

Post a Comment