SQL MCQs — Computer Science
4 practice MCQs
The correct answer is marked on every question, with its full explanation.
Computer ScienceSQL CSS PPSC FPSC NTSID: NWG-019
What is SQL mainly used for?
- ATo manage and ask questions of data stored in a database. ✓ Correct answer
- BTo design the physical parts of a computer.
- CTo remove viruses from a computer.
- DTo connect a computer to the Internet.
✓ Correct answer: To manage and ask questions of data stored in a database.
Full explanation
SQL is used 'To manage and ask questions of data stored in a database.' For example, SELECT is used to fetch rows from a table. Why the others are wrong: 'To design the physical parts of a computer.' — that is hardware design. 'To remove viruses from a computer.' — that is the job of antivirus software. 'To connect a computer to the Internet.' — that is the job of a network connection.
Computer ScienceSQL CSS PPSC FPSC NTSID: CMP-026
Which SQL command is used to get data from a table?
- ASELECT ✓ Correct answer
- BDELETE
- CINSERT
- DUPDATE
✓ Correct answer: SELECT
Full explanation
SELECT. It is the SQL command used to get data from a table. Why the others are wrong: DELETE — it removes rows from a table, it does not get data. INSERT — it adds new rows to a table, it does not get data. UPDATE — it changes existing rows in a table, it does not get data.
Computer ScienceSQL CSS PPSC FPSC NTSID: CMP-047
Which SQL command is used to add a new row of data into a table?
- ASELECT
- BINSERT ✓ Correct answer
- CDELETE
- DUPDATE
✓ Correct answer: INSERT
Full explanation
The SQL command used to add a new row of data into a table is INSERT. Why the others are wrong: SELECT — SELECT is used to get data from a table, not to add a row. DELETE — DELETE is used to remove rows from a table. UPDATE — UPDATE is used to change data that is already in a table.
Computer ScienceSQL CSS PPSC FPSC NTSID: CMP-070
Which SQL clause is used to filter the rows returned by a SELECT statement?
- AORDER BY
- BFROM
- CGROUP BY
- DWHERE ✓ Correct answer
✓ Correct answer: WHERE
Full explanation
The WHERE clause filters rows in a SELECT statement, so only the rows that meet the condition are returned. The correct clause is WHERE. Why the others are wrong: ORDER BY — it sorts the result, it does not filter rows. GROUP BY — it groups rows that share a value, it does not filter single rows. FROM — it names the table to read from, it does not filter rows.
Practise these MCQs interactively →
← Computer Science MCQs