/* 038- DROP & TRUNCATE */
-- create table "students" and insert records --
CREATE TABLE students(
id INT NOT NULL,
name VARCHAR(50) 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,age,gender,city,courses)
VALUES
(1,"Ram Kumar","19","M",1,1),
(2,"Sarita Kumari","22","F",2,2),
(3,"Salman Khan","20","M",1,1),
(4,"Juhi Chawla","18","F",3,3),
(5,"Anil Kapoor","22","M",1,3),
(6,"John Abraham","21","M",2,2),
(7,"Shahid Kapoor","20","M",1,1);
-- create table "city" and insert records --
CREATE TABLE city(
cid INT NOT NULL AUTO_INCREMENT,
cityname VARCHAR(50) NOT NULL,
PRIMARY KEY (cid)
);
INSERT INTO city(cityname)
VALUES('Agra'),
('Delhi'),
('Bhopal'),
('Jaipur'),
('Noida');
-- create table "courses" and insert records --
CREATE TABLE courses(
course_id INT NOT NULL AUTO_INCREMENT,
course_name VARCHAR(50) NOT NULL,
PRIMARY KEY (course_id)
);
INSERT INTO courses(course_name)
VALUES('Btech'),
('BCA'),
('MBA')
('BA')
('BCOM');
-- DROP & TRUNCATE --
TRUNCATE TABLE courses;
DROP TABLE courses;