0% found this document useful (0 votes)
36 views1 page

Lab 10

The document discusses creating and testing various indexes on tables in a Sakila database. It includes: 1) Creating indexes on the customer table's first name and last name columns and film table's description column; 2) Testing queries that successfully used the indexes; 3) Creating a unique index on the customer email column that prevented duplicate entries; 4) An index on the rental table's rental date was not used for a date-based query due to the large amount of data.

Uploaded by

Lam Pham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

Lab 10

The document discusses creating and testing various indexes on tables in a Sakila database. It includes: 1) Creating indexes on the customer table's first name and last name columns and film table's description column; 2) Testing queries that successfully used the indexes; 3) Creating a unique index on the customer email column that prevented duplicate entries; 4) An index on the rental table's rental date was not used for a date-based query due to the large amount of data.

Uploaded by

Lam Pham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

--Cau 1

CREATE INDEX `idx_customer_first_name_last_name` ON `sakila`.`customer`


(first_name, last_name);
--Tra loi: khi su dung cac cau truy van nhu trong VD, em thay index vua tao da duoc
su dung

--Cau 2
SELECT *
FROM actor
where first_name like "N%";

SELECT *
FROM actor
where first_name like "%N%";

--Cau 3
CREATE UNIQUE INDEX `idx_customer_email` ON `sakila`.`customer` (email);

INSERT INTO customer (customer_id,store_id,first_name,last_name,email, address_id)


VALUES (600,1,'a','b', '[email protected]', 605);

--Tra loi: khi them unique vao email thi se khong the them email trung, neu them se
hien loi nhu sau
--Duplicate entry '[email protected]' for key
'customer.idx_customer_email'
--Cau 4
CREATE INDEX `idx_film_description` ON `sakila`.`film` (description(255));

select *
from film
where description like 'A Boring%';

--Tra loi: co su dung index nhu VD

--Cau 5
CREATE INDEX `idx_rental_rental_date` ON `sakila`.`rental` (rental_date);

SELECT *
FROM rental
where year(rental_date) = 2005 and month(rental_date) = 5;

--Tra loi: Index khong duoc su dung do tep du lieu lon nhu hinh anh VD

You might also like