/* 040- INDEX */
-- create table "students" and insert records --
CREATE TABLE students(
id INT NOT NULL,
name VARCHAR(50) NOT NULL,
percentage INT NOT NULL,
dob DATE NOT NULL,
age INT NOT NULL,
gender VARCHAR(1) NOT NULL,
city INT NOT NULL,
courses INT NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (city) REFERENCES City (cid),
FOREIGN KEY (courses) REFERENCES Courses (course_id)
);
INSERT INTO students(id,name,percentage,dob,age,gender,city,courses)
VALUES
(1,"Ram Kumar","45","2000-05-10","19","M",1,1),
(2,"Sarita Kumari","85","1997-02-03","22","F",2,2),
(3,"Salman Khan","29","1999-11-12","20","M",1,1),
(4,"Juhi Chawla","47","2001-07-16","18","F",3,1),
(5,"Anil Kapoor","74","1997-01-03","22","M",1,3),
(6,"John Abraham","64","1998-08-10","21","M",2,2),
(7,"Shahid Kapoor","62","1999-12-08","20","M",1,3);
-- INDEX Examples --
SELECT * FROM students
WHERE dob > "1999-01-01";
-- create index--
CREATE INDEX studdob ON students (dob);
-- show index --
SHOW INDEX FROM students;
-- delete index --
DROP INDEX studdob ON students;