From the course: MySQL Advanced Topics (2019)
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
Multicolumn indexes - MySQL Tutorial
From the course: MySQL Advanced Topics (2019)
Multicolumn indexes
- [Narrator] MySQL allows you to create an index based upon more than one column in a table. So, we have an example of that here. Again, we're using the scratch database. And, creating this test table. You notice we have a primary key, and we have two strings, and now we have an index on both the strings, an index called twostrings, twostrs, and the index is based on both of these columns in this order. And we'll insert a few values. And we'll run a SELECT statement, and we'll show the index. So, I'm just going to execute all of this, and you'll see what happens here. First of all, our result of the SELECT statement. See we have another row, foo alpha, so they're in the order of this string1 and string2. Foo alpha comes before foo bar because string1 is indexed before string2. Another row is first because another sorts to the top, and this and that is last because this sorts after foo. So, we're getting exactly the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.