From the course: MySQL Advanced Topics
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Multi-column indexes - MySQL Tutorial
From the course: MySQL Advanced Topics
Multi-column indexes
- [Bill] Hi, I'm Bill Weinman. My SQL allows you to create an index based upon more than one column in a table. I've copied this block of SQL from chapter 1 exercise file, and we'll use the scratch database for this. So I'll execute that and open that database. And here we're going to create a table. We've done this before, a test table. It's got the three columns, the ID column, which is the primary key, and two string columns of type VARCHAR 128. And now it has this index. And you notice the index is named twostrs, two strings, and it's an index based on both string columns, string1 and string2. So I'll go ahead and I'll execute all of this and I'll insert some data into some rows into the table and I'll select, I'm going to do all of this at once. And you can see the result is that we have these two columns and four rows. So we inserted these four rows. Notice the order that I inserted them, foo, bar, this, that, another, row, food, alpha, and yet the order in which we are…
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.