From the course: Advanced SQL for Application Development

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Defining B-tree and hash indexes

Solution: Defining B-tree and hash indexes

From the course: Advanced SQL for Application Development

Start my 1-month free trial

Solution: Defining B-tree and hash indexes

(upbeat music) - [Instructor] Okay, the first part of the solution to the indexing challenge is to sue the CREATE INDEX command, followed by a name of an index, and then the term ON, followed by the name of the table, in this case, customers. And then we have a USING clause, and we'd say, USING B-tree, because we want this to be a B-tree index. And then we specify a list of the attributes that we want in the index. In this case, it's last name and first name. Now, not surprisingly, creating a hash index is similar. The solution there is again to use the CREATE INDEX command, specifying a name of the index, and then the ON clause, in this case it would be ON products, and then the USING clause, this cause we would be using hash, and again, followed by the list of attributes, but we only have one attribute that we're indexing in this case and that's product name. So that's the solution to the index challenge.

Contents