Index of SQL
Create a table:
QString querystr; querystr= "create table if not exists terminaldata (TerminalID varchar (20),"; QMap::iterator itC; / / for (itC = Map_variable_info.begin (); itC! = Map_variable_info.end (); + + itC) {querystr+=itC.value () + "varchar (20),";} querystr= querystr+ "SendServer1Flag int,SendServer2Flag int,CreateTime varchar (20)"; res = query.exec (querystr)
Create an index on the TerminalID column in the table:
Res = query.exec ("create index if not exists TerminalID_index on terminaldata (TerminalID)")
The role of an index: whenever a column is indexed, the query speed of that column will be faster when it is queried later. An index created on a column cannot be seen on a column, and when querying this column, it is still queried according to the column name, but because the column has been indexed, it is faster to query the column.