SQL-tutorial icon indicating copy to clipboard operation
SQL-tutorial copied to clipboard

SQL assignment that covers the basic usage of the INSERT, UPDATE, and DELETE statements.

Open Pankaj-Str opened this issue 1 year ago • 8 comments

Scenario: Assume you have a database named Company with a table named Employees. The Employees table has the following columns:

  • EmployeeID (integer, primary key)
  • FirstName (varchar)
  • LastName (varchar)
  • Department (varchar)
  • Salary (numeric)

Tasks:

  1. Insert Data:

    • Insert a new employee with the following details:
      • EmployeeID: 101
      • FirstName: 'John'
      • LastName: 'Doe'
      • Department: 'IT'
      • Salary: 60000
  2. Update Data:

    • Update the salary of the employee with EmployeeID 101 to 65000.
  3. Delete Data:

    • Delete the employee with EmployeeID 101 from the Employees table.

Submission Guidelines:

  • Create a SQL script that includes the necessary INSERT, UPDATE, and DELETE statements.
  • Include comments to explain each statement.
  • Assume that the database and table already exist.

Sample Solution:

-- Task 1: Insert Data
INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary)
VALUES (101, 'John', 'Doe', 'IT', 60000);

-- Task 2: Update Data
UPDATE Employees
SET Salary = 65000
WHERE EmployeeID = 101;

-- Task 3: Delete Data
DELETE FROM Employees
WHERE EmployeeID = 101;

Pankaj-Str avatar Nov 13 '23 06:11 Pankaj-Str