Practice high-yield Programming & Software Development MCQs on Databases Handling with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
39
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
47 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
39
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/39 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 39 questions answered.
Question 1 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The updated MySQL extension released with PHP 5 is typically referred to as.
Correct Answer: Option C — mysqly
Detailed Academic Explanation:
The updated MySQL extension with PHP 5 is known as MySQL and typically referred to as mysqli.
💡Key Conceptual Anchor:Databases Handling
Question 2 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following lines need to be uncommented or added in the php.ini file so as to enable mysqli extension?
Correct Answer: Option A — extension=php_mysqli.dll
Detailed Academic Explanation:
Also make sure that extension_dir directive points to the appropriate directory.
💡Key Conceptual Anchor:Databases Handling
Question 3 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In which version of PHP was MySQL Native Driver(also known as mysqlnd) introduced?
Correct Answer: Option D — PHP 5.3
Detailed Academic Explanation:
PHP required that MySQL client library be installed on the server from which PHP was communicating with MySQL, whether the MySQL server also happened to reside locally or elsewhere. PHP 5.3 removes this problem by introducing MySQL Native Driver.
💡Key Conceptual Anchor:Databases Handling
Question 4 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following statements instantiates the mysqli class?
Correct Answer: Option B — $mysqli = new mysqli()
Detailed Academic Explanation:
If you choose to interact with MySQL server using the object-oriented interface, you need to first instantiate the mysqli class via its constructor.
💡Key Conceptual Anchor:Databases Handling
Question 5 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following methods can be used to diagnose and display information about a MySQL connection error?
Correct Answer: Option C — mysqli_connect_errno()
Detailed Academic Explanation:
The mysqli extension includes a few features that can be used to capture error messages or alternatively you can use exceptions.
💡Key Conceptual Anchor:Databases Handling
Question 6 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method returns the error code generated from the execution of the last MySQL function?
Correct Answer: Option A — errno()
Detailed Academic Explanation:
Error numbers are often used in lieu of natural-language message to ease software internationalization efforts and allow for customization of error messages.
💡Key Conceptual Anchor:Databases Handling
Question 7 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following statements should be used to include a file?
Correct Answer: Option B — include ‘filename’
Detailed Academic Explanation:
An example of this-
💡Key Conceptual Anchor:Databases Handling
Question 8 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following methods is responsible for sending the query to the database?
Correct Answer: Option A — query()
Detailed Academic Explanation:
Its prototype looks like- class mysqli { mixed query(string query [, int resultmode]) }
💡Key Conceptual Anchor:Databases Handling
Question 9 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following methods recuperates any memory consumed by a result set?
Correct Answer: Option D — free()
Detailed Academic Explanation:
Once this method is executed, the result set is no longer available.
💡Key Conceptual Anchor:Databases Handling
Question 10 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the methods are used to manage result sets using both associative and indexed arrays?
Correct Answer: Option C — fetch_array() and fetch_row()
Detailed Academic Explanation:
Their prototype is as follows- calss mysqli_result { mixed fetch_array ([int resulttype]) } calss mysqli_result { mixed fetch_row() }
💡Key Conceptual Anchor:Databases Handling
Question 11 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following method is used to retrieve the number of rows affected by an INSERT, UPDATE, or DELETE query?
Correct Answer: Option B — affected_rows()
Detailed Academic Explanation:
The method num_rows() is only useful for determining the number of rows retrieved by a SELECT query. But to retrieve the number of rows affected by INSERT, UPDATE, or DELETE query, use affected_rows().
💡Key Conceptual Anchor:Databases Handling
Question 12 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which version of MySQL introduced the prepared statements?
Correct Answer: Option B — MySQL 4.1
Detailed Academic Explanation:
When the query() method is looped repeatedly it comes at a cost of both overhead, because of the need to repeatedly parsing of the almost identical query for validity, and coding convenience, because of the need to repeatedly reconfigure the query using the new values for each iteration. To help resolve the issues incurred by repeatedly executed queries, MySQL introduced prepared statements.
💡Key Conceptual Anchor:Databases Handling
Question 13 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following methods is used to execute the statement after the parameters have been bound?
Correct Answer: Option A — bind_param()
Detailed Academic Explanation:
Once the statement has been prepared, it needs to be executed. Exactly when it’s executed depends upon whether you want to work with bound parameters or bound results. In the case of bound parameters, you’d execute the statement after the parameters have been bound with the bind_param() method.
💡Key Conceptual Anchor:Databases Handling
Question 14 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following methods is used to recuperating prepared statements resources?
Correct Answer: Option D — close()
Detailed Academic Explanation:
Once you’ve finished using a prepared statement, the resources it requires can be recuperated with the close() method.
💡Key Conceptual Anchor:Databases Handling
Question 15 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method retrieves each row from the prepared statement result and assigns the fields to the bound results?
Correct Answer: Option C — fetch()
Detailed Academic Explanation:
Its prototype follows: class mysqli { boolean fetch() }
💡Key Conceptual Anchor:Databases Handling
Question 16 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method rolls back the present transaction?
Correct Answer: Option D — rollback()
Detailed Academic Explanation:
Its prototype follows: class mysqli { boolean rollback() }
💡Key Conceptual Anchor:Databases Handling
Question 17 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When you are building administrative links you’ll need to accept two arguments, which of the following are they?
Correct Answer: Option D — The current page and URL of the entry you are working with
Detailed Academic Explanation:
Your function should look like this: function adminLinks($page, $url) { //Build admin links here }
💡Key Conceptual Anchor:Databases Handling
Question 18 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Once your application can generate administrative links, you need to load those links into _________
Correct Answer: Option C — index.php
Detailed Academic Explanation:
You place your administrative links only on the full display of an entry, so you must place the call to load information from adminLinks() within a conditional statement
💡Key Conceptual Anchor:Databases Handling
Question 19 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The URLs in the administrative links won’t mean anything to admin.php unless you modify _________
Correct Answer: Option A — .htaccess
Detailed Academic Explanation:
You need to modify .htaccess with an additional rule that handles URLs passed in a link to admin.php.
💡Key Conceptual Anchor:Databases Handling
Question 20 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The (|/) tells the server to match ___________
Correct Answer: Option D — either nothing or a forward slash
Detailed Academic Explanation:
The vertical pipe character (|) is the regular expression equivalent of “or”.
💡Key Conceptual Anchor:Databases Handling
Question 21 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
([w-]+) will match ___________
Correct Answer: Option C — one or more word characters and/or hypens
Detailed Academic Explanation:
([w-]+), will match one or more word characters and/or hyphens—which is what your custom entry URLs consist.
💡Key Conceptual Anchor:Databases Handling
Question 22 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
You need to check whether ______ is set, to determine whether you’re editing an entry or creating a new one.
Correct Answer: Option A — $_GET[‘url’].
Detailed Academic Explanation:
If an entry is being edited, you need to load the existing entry data and save each piece in a variable.
💡Key Conceptual Anchor:Databases Handling
Question 23 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
To identify entries marked for deletion, you check whether $_GET[‘page’] == ‘delete’ inside __________
Correct Answer: Option C — admin.php
Detailed Academic Explanation:
In admin.php, you check whether $_GET[‘page’] == ‘delete’, then pass the entry URL to be deleted to a function.
💡Key Conceptual Anchor:Databases Handling
Question 24 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Your confirmation form submits your choice, via the _______ method, to ________
Correct Answer: Option D — POST admin.php
Detailed Academic Explanation:
To process this, you need to add an additional block of code to the top of admin.php that determines what choices you’ve made and act accordingly.
💡Key Conceptual Anchor:Databases Handling
Question 25 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When a user confirms that he wishes to delete an entry, that entry’s URL is passed to a function which removes the entry from the __________
Correct Answer: Option C — database
Detailed Academic Explanation:
If the function is successful, you send the user to the main page. If it fails, you stop execution of the script and display an error, letting the user know that something went wrong.
💡Key Conceptual Anchor:Databases Handling
Question 26 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following databases has PHP supported almost since the beginning?
Correct Answer: Option D — MySQL
Detailed Academic Explanation:
MySQL is the correct answer to “Which one of the following databases has PHP supported almost since the beginning”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 27 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following statements is used to create a table?
Correct Answer: Option A — CREATE TABLE table_name (column_name column_type)
Detailed Academic Explanation:
CREATE TABLE table_name (column_name column_type) is the correct answer to “Which one of the following statements is used to create a table”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 28 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following statements can be used to select the database?
Correct Answer: Option D — $mysqli->select_db(‘databasename’)
Detailed Academic Explanation:
$mysqli->select_db(‘databasename’) is the correct answer to “Which one of the following statements can be used to select the database”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 29 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If there is no error, then what will the error() method return?
Correct Answer: Option C — Empty String
Detailed Academic Explanation:
Empty String is the correct answer to “If there is no error, then what will the error() method return”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 30 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following DBMSs do not have a native PHP extension?
Correct Answer: Option E — None of the above
Detailed Academic Explanation:
None of the above is the correct answer to “Which of the following DBMSs do not have a native PHP extension”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 31 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In PHP in order to access MySQL database you will use:
Correct Answer: Option C — mysql_connect() function
Detailed Academic Explanation:
mysql_connect() function is the correct answer to “In PHP in order to access MySQL database you will use:”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 32 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Transactions are used to treat sets of SQL statements atomically.
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “Transactions are used to treat sets of SQL statements atomically.”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 33 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
SQL is not case sensitive. SELECT is the same as select.
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “SQL is not case sensitive. SELECT is the same as select.”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 34 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not an SQL aggregate function?
Correct Answer: Option E — CURRENT_DATE()
Detailed Academic Explanation:
CURRENT_DATE() is the correct answer to “Which of the following is not an SQL aggregate function”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 35 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the DESC keyword do in the following query? SELECT * FROM MY_TABLE WHERE ID > 0 ORDER BY ID, NAME DESC"
Correct Answer: Option C — It causes rows with the same ID to be sorted by NAME in descending order
Detailed Academic Explanation:
It causes rows with the same ID to be sorted by NAME in descending order is the correct answer to “What does the DESC keyword do in the following query? SELECT * FROM MY_TABLE WHERE ID > 0 ORDER BY ID, NAME DESC"”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 36 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The ............. statement is used to delete a table.
Correct Answer: Option A — DROP TABLE
Detailed Academic Explanation:
DROP TABLE is the correct answer to “The ............. statement is used to delete a table.”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 37 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will happen at the end of the following sequence of SQL commands? BEGIN TRANSACTION DELETE FROM MYTABLE WHERE ID=1 DELETE FROM OTHERTABLE ROLLBACK TRANSACTION
Correct Answer: Option E — The database will remain unchanged
Detailed Academic Explanation:
The database will remain unchanged is the correct answer to “What will happen at the end of the following sequence of SQL commands? BEGIN TRANSACTION DELETE FROM MYTABLE WHERE ID=1 DELETE FROM OTHERTABLE ROLLBACK TRANSACTION”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 38 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Use the .............. to delete the data inside the table, and not the table itself?
Correct Answer: Option C — TRUNCATE TABLE
Detailed Academic Explanation:
TRUNCATE TABLE is the correct answer to “Use the .............. to delete the data inside the table, and not the table itself”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
Question 39 of 39
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Can joins be nested?
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “Can joins be nested”. This question is standard in competitive examination syllabi for Databases Handling.
💡Key Conceptual Anchor:Databases Handling
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.