books with columns id (integer primary key), title (text), and isbn (text).id, title, and isbn values.idx_books_isbn_hash on the isbn column of the books table.Jump into concepts and practice - no test required
books with columns id (integer primary key), title (text), and isbn (text).id, title, and isbn values.idx_books_isbn_hash on the isbn column of the books table.books tablebooks with three columns: id as an integer primary key, title as text, and isbn as text.Use CREATE TABLE books and define id as INTEGER PRIMARY KEY.
booksbooks table with exact values:id=1, title='The Great Gatsby', isbn='9780743273565'id=2, title='1984', isbn='9780451524935'id=3, title='To Kill a Mockingbird', isbn='9780061120084'Use a single INSERT INTO books (id, title, isbn) VALUES statement with all three rows.
isbnidx_books_isbn_hash on the isbn column of the books table.Use CREATE INDEX idx_books_isbn_hash ON books USING HASH (isbn);
idx_books_isbn_hash is created on the isbn column.Add a comment line starting with -- that mentions the hash index idx_books_isbn_hash on isbn.
What is the main advantage of using a hash index in PostgreSQL?
Which of the following is the correct syntax to create a hash index on the email column of a table named users?
?
Given the table products(id INT, name TEXT) with a hash index on id, what will the query SELECT * FROM products WHERE id = 10; most likely use?
id column: id = 10.id, PostgreSQL will use a hash index scan to quickly find rows where id equals 10.Consider the following SQL commands:CREATE TABLE employees(id INT, name TEXT);
CREATE INDEX emp_id_hash ON employees USING hash (id);
SELECT * FROM employees WHERE id > 5;
What is the problem with using the hash index in this query?
id > 5.id > 5. -> Option CYou have a large table orders(order_id INT, customer_id INT, status TEXT). You often query orders by customer_id with equality conditions, but sometimes you query by status with range-like conditions (e.g., status > 'A'). Which indexing strategy is best?
customer_id. B-tree indexes support range queries, so use one on status.customer_id and a B-tree index on status. correctly assigns hash index for equality and B-tree for range. Create hash indexes on both customer_id and status. wrongly uses hash for range. Create a B-tree index on customer_id only. misses index on status. Create no indexes to avoid overhead. ignores performance.customer_id and a B-tree index on status. -> Option A