04-04 DELETE FROM

01

Use this Table

DROP TABLE student;
CREATE TABLE student(
    student_id INT AUTO_INCREMENT,
    name VARCHAR(20),
    major VARCHAR(20),
    PRIMARY KEY(student_id)
);
INSERT INTO student(name,major) VALUES('John','Biology');
INSERT INTO student(name,major) VALUES('Kate','Sociology');
INSERT INTO student(name,major) VALUES('Claire','Chemistry');
INSERT INTO student(name,major) VALUES('Jack','Biology');
INSERT INTO student(name,major) VALUES('Mike','Computer Science');
SELECT * FROM student;

02

Delete a specific row with the WHERE keyword

DELETE FROM student
WHERE student_id = 3;
                

This will delete the row with 'Jack' from the above the top table

03

We can delete all the rows from the table,

DELETE FROM student;
SELECT * FROM student;

BUT it will NOT delete the table. If you SELECT * FROM student; you will still see the table.