0
0
SQLquery~5 mins

CREATE INDEX syntax in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the CREATE INDEX statement in SQL?
It creates an index on one or more columns of a table to speed up data retrieval.
Click to reveal answer
beginner
Write the basic syntax of CREATE INDEX.
CREATE INDEX index_name ON table_name (column1, column2, ...);
Click to reveal answer
intermediate
Can you create an index on multiple columns? How?
Yes, by listing multiple columns separated by commas inside parentheses after the table name.
Click to reveal answer
intermediate
What is a unique index and how do you create it?
A unique index ensures all values in the indexed column(s) are distinct. Use CREATE UNIQUE INDEX instead of just CREATE INDEX.
Click to reveal answer
intermediate
Does creating an index affect data insertion speed? Why or why not?
Yes, because the database must update the index every time data is inserted, which adds overhead.
Click to reveal answer
What does the CREATE INDEX statement do?
ACreates a new table
BDeletes data from a table
CSpeeds up data retrieval by creating an index
DUpdates existing data
Which of the following is the correct syntax to create an index on the column name in the table users?
ACREATE INDEX users ON name;
BCREATE INDEX idx_name ON users (name);
CCREATE INDEX name ON users;
DCREATE INDEX users_name (name);
How do you create a unique index?
ACREATE UNIQUE INDEX index_name ON table_name (column);
BCREATE INDEX UNIQUE index_name ON table_name (column);
CCREATE INDEX index_name UNIQUE ON table_name (column);
DCREATE INDEX index_name ON table_name UNIQUE (column);
Can you create an index on more than one column?
ANo, indexes only work on single columns
BYes, by listing columns separated by commas inside parentheses
CYes, but only if columns are of the same data type
DNo, you must create separate indexes for each column
What is a downside of creating many indexes on a table?
AIt slows down data retrieval
BIt uses less disk space
CIt slows down data insertion and updates
DIt deletes data accidentally
Explain the syntax and purpose of the CREATE INDEX statement.
Think about how you tell the database to make searching faster.
You got /5 concepts.
    Describe the trade-offs of using indexes in a database.
    Consider both benefits and costs of indexes.
    You got /4 concepts.