Insert Records: Insert 5 records into each table (Vehicles, Trips, and Maintenance).Update Records: Update the Year of a vehicle to 2020 where the Year of the vehicle is 2022.Select Records: Select all records from the Vehicles table to view the current trips.Delete Records: Delete one record from the Trips table based on TripId is 2.Select Records: Select all the records from Trips and Maintenance table
Question
Insert Records: Insert 5 records into each table (Vehicles, Trips, and Maintenance).Update Records: Update the Year of a vehicle to 2020 where the Year of the vehicle is 2022.Select Records: Select all records from the Vehicles table to view the current trips.Delete Records: Delete one record from the Trips table based on TripId is 2.Select Records: Select all the records from Trips and Maintenance table
Solution
Sure, here are the SQL commands for each of the operations you mentioned:
- Insert Records:
INSERT INTO Vehicles VALUES (1, 'Car', 'Toyota', 2022);
INSERT INTO Vehicles VALUES (2, 'Truck', 'Ford', 2022);
INSERT INTO Vehicles VALUES (3, 'Motorcycle', 'Honda', 2022);
INSERT INTO Vehicles VALUES (4, 'Car', 'Hyundai', 2022);
INSERT INTO Vehicles VALUES (5, 'Truck', 'Chevrolet', 2022);
INSERT INTO Trips VALUES (1, 1, '2022-01-01', '2022-01-02');
INSERT INTO Trips VALUES (2, 2, '2022-01-03', '2022-01-04');
INSERT INTO Trips VALUES (3, 3, '2022-01-05', '2022-01-06');
INSERT INTO Trips VALUES (4, 4, '2022-01-07', '2022-01-08');
INSERT INTO Trips VALUES (5, 5, '2022-01-09', '2022-01-10');
INSERT INTO Maintenance VALUES (1, 1, '2022-01-01', 'Oil Change');
INSERT INTO Maintenance VALUES (2, 2, '2022-01-03', 'Tire Rotation');
INSERT INTO Maintenance VALUES (3, 3, '2022-01-05', 'Brake Check');
INSERT INTO Maintenance VALUES (4, 4, '2022-01-07', 'Engine Tune-up');
INSERT INTO Maintenance VALUES (5, 5, '2022-01-09', 'Transmission Check');
- Update Records:
UPDATE Vehicles SET Year = 2020 WHERE Year = 2022;
- Select Records:
SELECT * FROM Vehicles;
- Delete Records:
DELETE FROM Trips WHERE TripId = 2;
- Select Records:
SELECT * FROM Trips;
SELECT * FROM Maintenance;
Please replace the values in the INSERT statements with the actual data you want to insert.
Similar Questions
eid ename esalary email dob1 XYZ 3000.89 [email protected] 1990-08-302 ABC 2300.90 [email protected] 1980-03-211] Write Query to insert 2 Records in above table using single query.2]Write Query to update esalary to 4000.68 and dob to 1993-08-30 of employee whose eid is 1 in a single query.3] Write Query to delete all records from the table in single query.
Diego is working as an intern at a vacation rental company. His task is to manage and analyze rental and booking data. The database admin has already created two tables, Rentals and Bookings. Diego needs to perform several operations on these tables based on specific conditions.Table Name: RentalsTable Name: BookingsSample Input Records:Tasks for DiegoInsert Records: Insert at least 5 records into the Rentals and Bookings tables with the values mentioned.Update Prices: Update the PricePerNight of rentals where PricePerNight is greater than $100Delete Bookings: Remove bookings from the Bookings table where the BookingDate is before '2024-01-01' and the RentalID is not equal to 101, 102, 103.Select Rentals: Retrieve all rentals located at 'Beach' where the PricePerNight is less than $150.
Write an UPDATE statement on the customers table to SET the years_old column to 42 for any customer with a last_name of Hall.
The UNION SQL clause can be used with ____________SELECT clause onlyDELETE and UPDATE clausesUPDATE clause onlyAll of the mentioned
Question 3You have a new database named 2023_students. You have an old database named 2022_students. The 2022_students database has a table in it named freshmen. All the students who were freshmen in 2022 will be returning as sophomores in 2023. You need to copy the whole freshmen table to the 2023_students database. The new table in the 2023_students database should be named sophmores.You have executed the USE 2023_students; statement.What statement should you execute next?1 pointCREATE TABLE sophomores AS SELECT * FROM freshmenCREATE TABLE sophomores AS 2022_students.freshmen CREATE TABLE sophomores AS SELECT * FROM 2022_students.freshmenCREATE TABLE 2023_students.sophomores AS SELECT * FROM freshmen
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.