Sqlite_orm: How can I create index for table?

Created on 9 Jul 2020  路  5Comments  路  Source: fnc12/sqlite_orm

I see index is support in readme.md, is there example for it?

question

All 5 comments

is the issue actual?

is the issue actual?

It's worked. but if I created index before

sqlite_orm::make_storage(dbName,
                              sqlite_orm::make_index("ids_first_name", &User::getFirstName),
                              sqlite_orm::make_table("users",
                                                    sqlite_orm::make_column("id", &User::setId, &User::getId, sqlite_orm::autoincrement(), sqlite_orm::primary_key()),
                                                    sqlite_orm::make_column("first_name", &User::setFirstName, &User::getFirstName),
                                                    sqlite_orm::make_column("last_name", &User::setLastName, &User::getLastName)));

Then I recreate table without index

sqlite_orm::make_storage(dbName,
                              sqlite_orm::make_table("users",
                                                    sqlite_orm::make_column("id", &User::setId, &User::getId, sqlite_orm::autoincrement(), sqlite_orm::primary_key()),
                                                    sqlite_orm::make_column("first_name", &User::setFirstName, &User::getFirstName),
                                                    sqlite_orm::make_column("last_name", &User::setLastName, &User::getLastName)));

Now I see the table by sqlite3 shell, the index is still existed.

CREATE TABLE 'users' ( 'id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , 'first_name' TEXT NOT NULL , 'last_name' TEXT NOT NULL );
CREATE INDEX 'ids_first_name' ON 'users' ( 'first_name' ) ;

Order matters cause when index is being created the table must exist. Is the issue actual?

It's works. Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

juandent picture juandent  路  6Comments

sivabudh picture sivabudh  路  7Comments

steven-pearson picture steven-pearson  路  4Comments

ncoder-1 picture ncoder-1  路  5Comments

daitouguan picture daitouguan  路  9Comments