0% found this document useful (0 votes)
2 views

MCQ on UNIT 5 Open Source Database and Application

The document contains a series of multiple-choice questions (MCQs) related to MySQL, covering topics such as database management, SQL commands, and PHP integration. Each question is followed by the correct answer, providing a comprehensive review of key concepts in open source databases and applications. It serves as a study guide for students at Shree Siddheshwar Women’s College of Engineering, Solapur.

Uploaded by

CO236Srushti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MCQ on UNIT 5 Open Source Database and Application

The document contains a series of multiple-choice questions (MCQs) related to MySQL, covering topics such as database management, SQL commands, and PHP integration. Each question is followed by the correct answer, providing a comprehensive review of key concepts in open source databases and applications. It serves as a study guide for students at Shree Siddheshwar Women’s College of Engineering, Solapur.

Uploaded by

CO236Srushti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Shree Siddheshwar Women’s College of Engineering, Solapur

MCQ on UNIT 5 Open Source Database and Application


1) What is MySQL?
A) A programming language
B) A relational database management system
C) A web server
D) A text editor
Answer: B) A relational database management system

2) Which command is used to check the MySQL server status?


A) mysql --status
B) systemctl status mysql
C) mysqlcheck
D) checkmysql
Answer: B) systemctl status mysql

3) Which file is used to configure the MySQL server?


A) my.cnf
B) mysql.ini
C) config.cnf
D) mysql.cfg
Answer: A) my.cnf

4) What is the default port number for MySQL?


A) 3306
B) 1521
C) 5432
D) 1433
Answer: A) 3306

Open Source Technology (OST) TY (E&TC) Page 1


Shree Siddheshwar Women’s College of Engineering, Solapur

5) How do you start MySQL service on Linux?


A) systemctl start mysql
B) mysql start
C) mysql-server start
D) service mysql run
Answer: A) systemctl start mysql

6) Which command is used to create a new MySQL database?


A) CREATE DATABASE dbname;
B) NEW DATABASE dbname;
C) ADD DATABASE dbname;
D) INIT DATABASE dbname;
Answer: A) CREATE DATABASE dbname;

7) How do you list all databases in MySQL?


A) SHOW DATABASES;
B) LIST DATABASES;
C) VIEW DATABASES;
D) DISPLAY DATABASES;
Answer: A) SHOW DATABASES;

8) What command is used to select a MySQL database?


A) USE database_name;
B) SELECT DATABASE database_name;
C) CHOOSE database_name;
D) SWITCH database_name;
Answer: A) USE database_name;

9) How do you delete a MySQL database?


A) DROP DATABASE dbname;
B) DELETE DATABASE dbname;
C) REMOVE DATABASE dbname;

Open Source Technology (OST) TY (E&TC) Page 2


Shree Siddheshwar Women’s College of Engineering, Solapur

D) ERASE DATABASE dbname;


Answer: A) DROP DATABASE dbname;

10) Which SQL statement is used to create a new table?


A) CREATE TABLE table_name (...);
B) ADD TABLE table_name (...);
C) MAKE TABLE table_name (...);
D) NEW TABLE table_name (...);
Answer: A) CREATE TABLE table_name (...);

11) Which data type is used for storing date values in MySQL?
A) DATE
B) DATETIME
C) TIMESTAMP
D) All of the above
Answer: D) All of the above

12) How do you insert data into a MySQL table?


A) INSERT INTO table_name VALUES (...);
B) ADD INTO table_name VALUES (...);
C) NEW INTO table_name VALUES (...);
D) UPDATE table_name VALUES (...);
Answer: A) INSERT INTO table_name VALUES (...);

13) How do you retrieve data from a MySQL table?


A) SELECT * FROM table_name;
B) GET * FROM table_name;
C) FETCH * FROM table_name;
D) RETRIEVE * FROM table_name;
Answer: A) SELECT * FROM table_name;

Open Source Technology (OST) TY (E&TC) Page 3


Shree Siddheshwar Women’s College of Engineering, Solapur

14) How do you update records in MySQL?


A) UPDATE table_name SET column=value WHERE condition;
B) MODIFY table_name SET column=value WHERE condition;
C) ALTER table_name SET column=value WHERE condition;
D) CHANGE table_name SET column=value WHERE condition;
Answer: A) UPDATE table_name SET column=value WHERE condition;

15) How do you delete records from a table in MySQL?


A) DELETE FROM table_name WHERE condition;
B) REMOVE FROM table_name WHERE condition;
C) ERASE FROM table_name WHERE condition;
D) DROP FROM table_name WHERE condition;
Answer: A) DELETE FROM table_name WHERE condition;

16) What is the purpose of the REPLACE statement in MySQL?


A) To insert or update a record based on key duplication
B) To delete a record permanently
C) To change the table structure
D) To remove duplicate records
Answer: A) To insert or update a record based on key duplication

17) Which MySQL function returns the current date?


A) CURDATE()
B) NOW()
C) SYSDATE()
D) All of the above
Answer: D) All of the above

18) What is the function of the TIMESTAMP data type?


A) Stores date and time
B) Stores only date
C) Stores only time

Open Source Technology (OST) TY (E&TC) Page 4


Shree Siddheshwar Women’s College of Engineering, Solapur

D) Stores a unique key


Answer: A) Stores date and time

19) What is PHP?


A) A server-side scripting language
B) A database system
C) A front-end framework
D) A web server
Answer: A) A server-side scripting language

20) How do you connect to a MySQL database using PHP?


A) mysqli_connect()
B) mysql_connect()
C) db_connect()
D) connect_db()
Answer: A) mysqli_connect()

21) Which PHP function is used to execute an SQL query?


A) mysqli_query()
B) mysql_query()
C) execute_query()
D) run_query()
Answer: A) mysqli_query()

22) How do you fetch data from a MySQL database in PHP?


A) mysqli_fetch_assoc()
B) mysql_fetch_assoc()
C) fetch_assoc()
D) get_assoc()
Answer: A) mysqli_fetch_assoc()

Open Source Technology (OST) TY (E&TC) Page 5


Shree Siddheshwar Women’s College of Engineering, Solapur

23) What is the purpose of mysqli_num_rows()?


A) Counts the number of rows returned by a query
B) Retrieves data from a database
C) Deletes records from a table
D) Returns the total number of columns
Answer: A) Counts the number of rows returned by a query

24) How do you close a MySQL connection in PHP?


A) mysqli_close()
B) mysql_close()
C) db_close()
D) disconnect()
Answer: A) mysqli_close()

25) Which SQL clause is used to filter query results?


A) WHERE
B) FILTER
C) SELECT
D) ORDER BY
Answer: A) WHERE

26) How do you retrieve only unique values from a column in MySQL?
A) DISTINCT
B) UNIQUE
C) DIFFERENT
D) FILTER
Answer: A) DISTINCT

27) What is the default storage engine in MySQL 8?


A) InnoDB
B) MyISAM
C) MEMORY

Open Source Technology (OST) TY (E&TC) Page 6


Shree Siddheshwar Women’s College of Engineering, Solapur

D) CSV
Answer: A) InnoDB

28) What does the MySQL TRUNCATE command do?


A) Deletes all rows but keeps the table structure
B) Deletes a table permanently
C) Deletes only duplicate rows
D) Deletes selected rows
Answer: A) Deletes all rows but keeps the table structure

29) What is the primary function of an index in MySQL?


A) Speed up data retrieval
B) Store data
C) Encrypt data
D) Increase storage size
Answer: A) Speed up data retrieval

30) Which command is used to change a column’s data type?


A) ALTER TABLE
B) MODIFY TABLE
C) CHANGE TABLE
D) UPDATE TABLE
Answer: A) ALTER TABLE

31) How do you add a column to an existing table?


A) ALTER TABLE table_name ADD column_name data_type;
B) MODIFY TABLE table_name ADD column_name data_type;
C) INSERT COLUMN table_name ADD column_name data_type;
D) ADD COLUMN table_name ADD column_name data_type;
Answer: A) ALTER TABLE table_name ADD column_name data_type;

Open Source Technology (OST) TY (E&TC) Page 7


Shree Siddheshwar Women’s College of Engineering, Solapur

32) What does the MySQL function NOW() return?


A) Current date and time
B) Current date only
C) Current time only
D) Server start time
Answer: A) Current date and time

33) How do you find the highest value in a column?


A) SELECT MAX(column_name) FROM table_name;
B) SELECT HIGHEST(column_name) FROM table_name;
C) SELECT TOP(column_name) FROM table_name;
D) SELECT LARGE(column_name) FROM table_name;
Answer: A) SELECT MAX(column_name) FROM table_name;

34) What does GROUP BY do in MySQL?


A) Groups rows with the same values in specified columns
B) Sorts the results
C) Counts the number of rows
D) Filters duplicate values
Answer: A) Groups rows with the same values in specified columns

35) What is the purpose of HAVING in SQL?


A) Filters grouped results
B) Filters individual rows
C) Joins multiple tables
D) Sorts results
Answer: A) Filters grouped results

36) How do you create a user in MySQL?


A) CREATE USER 'username'@'host' IDENTIFIED BY 'password';
B) ADD USER 'username'@'host' IDENTIFIED BY 'password';
C) NEW USER 'username'@'host' IDENTIFIED BY 'password';

Open Source Technology (OST) TY (E&TC) Page 8


Shree Siddheshwar Women’s College of Engineering, Solapur

D) INSERT USER 'username'@'host' IDENTIFIED BY 'password';


Answer: A) CREATE USER 'username'@'host' IDENTIFIED BY 'password';

37) How do you grant all privileges to a MySQL user?


A) GRANT ALL PRIVILEGES ON . TO 'user'@'host';
B) GIVE ALL ON . TO 'user'@'host';
C) SET PERMISSIONS ON . TO 'user'@'host';
D) ALLOW ALL TO 'user'@'host';
Answer: A) GRANT ALL PRIVILEGES ON . TO 'user'@'host';

38) What does the LIMIT clause do in MySQL?


A) Restricts the number of rows returned
B) Sets maximum storage size
C) Limits the number of columns
D) Controls access to the database
Answer: A) Restricts the number of rows returned

39) How do you remove a column from a table?


A) ALTER TABLE table_name DROP COLUMN column_name;
B) DELETE COLUMN table_name column_name;
C) REMOVE COLUMN table_name column_name;
D) ERASE COLUMN table_name column_name;
Answer: A) ALTER TABLE table_name DROP COLUMN column_name;

40) Which PHP function connects to a MySQL database?


A) mysqli_connect()
B) mysql_start()
C) connect_mysql()
D) db_connect()
Answer: A) mysqli_connect()

Open Source Technology (OST) TY (E&TC) Page 9


Shree Siddheshwar Women’s College of Engineering, Solapur

41) What does mysqli_fetch_array() do?


A) Fetches a row as an array
B) Fetches only column names
C) Fetches only numeric values
D) Fetches all rows at once
Answer: A) Fetches a row as an array

42) What is the difference between mysqli_fetch_assoc() and mysqli_fetch_array()?


A) mysqli_fetch_assoc() returns an associative array, while mysqli_fetch_array()
returns both numeric and associative arrays.
B) Both return the same result
C) mysqli_fetch_assoc() returns only numeric values
D) mysqli_fetch_array() only returns column names
Answer: A) mysqli_fetch_assoc() returns an associative array, while
mysqli_fetch_array() returns both numeric and associative arrays.

43) How do you check for errors in a MySQL query in PHP?


A) mysqli_error()
B) mysql_error()
C) error_query()
D) check_error()
Answer: A) mysqli_error()

44) How do you prevent SQL injection in PHP?


A) Use prepared statements
B) Use raw queries
C) Use JavaScript validation only
D) Ignore it
Answer: A) Use prepared statements

Open Source Technology (OST) TY (E&TC) Page 10


Shree Siddheshwar Women’s College of Engineering, Solapur

45) How do you insert data into MySQL using PHP?


A) mysqli_query($conn, "INSERT INTO table_name VALUES (...)");
B) query_insert($conn, "INSERT INTO table_name VALUES (...)");
C) insert_sql($conn, "INSERT INTO table_name VALUES (...)");
D) save_into($conn, "INSERT INTO table_name VALUES (...)");
Answer: A) mysqli_query($conn, "INSERT INTO table_name VALUES (...)");

46) How do you retrieve data from MySQL using PHP?


A) mysqli_query($conn, "SELECT * FROM table_name");
B) query_get($conn, "SELECT * FROM table_name");
C) fetch_sql($conn, "SELECT * FROM table_name");
D) retrieve_from($conn, "SELECT * FROM table_name");
Answer: A) mysqli_query($conn, "SELECT * FROM table_name");

47) Which PHP function closes a MySQL connection?


A) mysqli_close($conn);
B) mysql_end($conn);
C) close_db($conn);
D) disconnect($conn);
Answer: A) mysqli_close($conn);

48) How do you sort query results in ascending order?


A) ORDER BY column_name ASC
B) SORT BY column_name ASC
C) ARRANGE BY column_name ASC
D) FILTER BY column_name ASC
Answer: A) ORDER BY column_name ASC

49) How do you retrieve the last inserted ID in MySQL?


A) mysqli_insert_id($conn)
B) get_last_id($conn)
C) retrieve_id($conn)

Open Source Technology (OST) TY (E&TC) Page 11


Shree Siddheshwar Women’s College of Engineering, Solapur

D) last_insert($conn)
Answer: A) mysqli_insert_id($conn)

Open Source Technology (OST) TY (E&TC) Page 12

You might also like