A school science department stores laboratory equipment details in a table called EQUIPMENT. EquipID ItemName Lab Quantity Condition LastChecked EQ01 Micros...

Assessment: Computer Science 0478 | Paper 2 Mock 01 | Algorithms, Programming and Logic Subject: Computer Science - 0478

Question 1 Report

A school science department stores laboratory equipment details in a table called EQUIPMENT.

EquipIDItemNameLabQuantityConditionLastChecked
EQ01MicroscopeLab112Good2024-01-15
EQ02Bunsen BurnerLab28Fair2024-02-10
EQ03Balance ScaleLab16Good2024-01-15
EQ04Test Tube RackLab315Good2024-03-01
EQ05Beaker SetLab210Poor2023-11-20

(a) Write an SQL INSERT statement to add a new record: EquipID 'EQ06', ItemName 'Thermometer', Lab 'Lab1', Quantity 20, Condition 'Good', LastChecked '2024-04-01'. [1]

Answer Details

(a) The SQL INSERT statement adds a new row to a table. [1]

INSERT INTO EQUIPMENT VALUES ('EQ06', 'Thermometer', 'Lab1', 20, 'Good', '2024-04-01')

When using INSERT INTO ... VALUES without specifying column names, you must provide values for every column in the same order they appear in the table definition. The values must match the data types of each column: string values like 'EQ06' and 'Thermometer' are enclosed in single quotes, while the integer value 20 (Quantity) has no quotes. The date '2024-04-01' is treated as a string in this format.

An alternative explicit form is:

INSERT INTO EQUIPMENT (EquipID, ItemName, Lab, Quantity, Condition, LastChecked)
VALUES ('EQ06', 'Thermometer', 'Lab1', 20, 'Good', '2024-04-01')

This explicit form lists the column names, making the statement more readable and less error-prone, but both forms are accepted.

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning