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:
sql9123CREATE INDEX index_name ON table_nameUSING 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
9
1
2
3
4
5
-- 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?
Tak for dine kommentarer!
Sektion 2. Kapitel 3
single
9
1
2
3
4
5
-- Drop the index if it exists
DROP INDEX IF EXISTS balance_index;
-- Create the index
___;
No query executed yet... |
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat