![]() Mysql> CREATE UNIQUE INDEX AUTHOR_INDEX ON tutorials_tbl (tutorial_author DESC) If you want to index the values in a column in a descending order, you can add the reserved word DESC after the column name. A Simple index allows duplicate values in a table. Just omit the UNIQUE keyword from the query to create a simple index. You can create a simple index on a table. ![]() You can use one or more columns to create an index.įor example, we can create an index on tutorials_tbl using tutorial_author.ĬREATE UNIQUE INDEX AUTHOR_INDEX ON tutorials_tbl (tutorial_author) Here is the syntax to create an Index on a table.ĬREATE UNIQUE INDEX index_name ON table_name ( column1, column2.) A unique index means that two rows cannot have the same index value. You can create a unique index on a table. The reason is that while doing insert or update, a database needs to insert or update the index values as well. The INSERT and UPDATE statements take more time on tables having indexes, whereas the SELECT statements become fast on those tables. The users cannot see the indexes, they are just used to speed up queries and will be used by the Database Search Engine to locate records very fast. Practically, indexes are also a type of tables, which keep primary key or index field and a pointer to each record into the actual table. While creating index, it should be taken into consideration which all columns will be used to make SQL queries and create one or more indexes on those columns. Indexes can be created using one or more columns, providing the basis for both rapid random lookups and efficient ordering of access to records. It may not always be possible, and sometimes you will have to rework the queries to take advantage of existing indexes.A database index is a data structure that improves the speed of operations in a table.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |