🔥 Ready to level up your MySQL skills? Join us in this MySQL tutorial as we dive into the powerful DELETE and DROP statements using MySQL Workbench! Whether you're a database beginner or an experienced SQL pro, understanding these statements is essential for efficient data management.
🗑️ DELETE Statement:
Learn how to remove specific rows from your MySQL database using the DELETE statement. We'll cover filtering criteria, the WHERE clause, and best practices to ensure data integrity.
💥 DROP Statement:
Discover how to obliterate entire database objects like tables with the DROP statement. We'll explore the DROP TABLE statement in detail and discuss the consequences, so you wield this command with confidence.
🚀 By the end of this tutorial, you'll have a strong grasp of these crucial SQL statements, allowing you to manipulate your MySQL databases like a pro.
---------------------------------------
⭐ Follow us on Social Media ⭐
💻 LinkedIn/onecodecamp
🐦 Twiter/onecodecamp
📷 Instagram/onecodecamp
📱 Facebook/onecodecamp
=====================================
DATABASE for the ACTIVITY
-- Create the TutorialDB database
CREATE DATABASE TutorialDB;
-- Switch to the TutorialDB database
USE TutorialDB;
-- Create the Students table
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Age INT
);
-- Insert sample data into the Students table
INSERT INTO Students (StudentID, FirstName, LastName, Age)
VALUES
(1, 'John', 'Doe', 28),
(2, 'Jane', 'Smith', 22),
(3, 'Michael', 'Johnson', 30),
(4, 'Emily', 'Williams', 19),
(5, 'David', 'Brown', 25);
-- Create the Orders table
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
ProductName VARCHAR(100),
Quantity INT,
Status VARCHAR(20)
);
-- Insert sample data into the Orders table
INSERT INTO Orders (OrderID, ProductName, Quantity, Status)
VALUES
(101, 'Widget A', 10, 'Shipped'),
(102, 'Widget B', 5, 'Cancelled'),
(103, 'Widget A', 8, 'Processing'),
(104, 'Gadget X', 3, 'Shipped'),
(105, 'Gadget Y', 2, 'Cancelled');
-- Create the Products table
CREATE TABLE Products (
ProductID INT PRIMARY KEY,
ProductName VARCHAR(100)
);
-- Insert sample data into the Products table
INSERT INTO Products (ProductID, ProductName)
VALUES
(1, 'Widget A'),
(2, 'Widget B'),
(3, 'Gadget X'),
(4, 'Gadget Y'),
(5, 'Widget A');
-- Create the TemporaryData table
CREATE TABLE TemporaryData (
ID INT PRIMARY KEY,
DataValue VARCHAR(50)
);
-- Insert sample data into the TemporaryData table
INSERT INTO TemporaryData (ID, DataValue)
VALUES
(1, 'Sample Data 1'),
(2, 'Sample Data 2'),
(3, 'Sample Data 3');
=====================================================
Информация по комментариям в разработке