Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Creating B-tree Index | Query optimization.Indexes
Advanced Techniques in SQL

book
Challenge: Creating B-tree Index

Opgave

Swipe to start coding

We have considered in the previous chapter that the B-tree index can be created using the following syntax:

sql
CREATE INDEX index_name ON table_name
USING BTREE (column_name1, column_name2,...);

Now let's continue working with the BankAccounts table as in the previous chapter. Given that we frequently work with balance ranges when dealing with bank accounts, it would be beneficial to create a B-tree index on the balance column.

Your task is to create a new B-tree index on the balance column of the BankAccounts table. Please ensure that you directly specify a B-tree index and do not rely on the default index:

  • specify balance_index as the name of the index.
  • the index is created for BankAccounts table.
  • the index is created using balance column.

Løsning

-- Drop the index if it exists
DROP INDEX IF EXISTS balance_index;

-- Create the index
CREATE INDEX balance_index ON BankAccounts USING BTREE (balance);
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 3
single

single

-- Drop the index if it exists
DROP INDEX IF EXISTS balance_index;

-- Create the index
___;
Query ResultQuery Result
No query executed yet...

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

We use cookies to make your experience better!
some-alt