MySQL Questions and Answers – MySQL Setup – 2

This set of MySQL Interview Questions and Answers focuses on “MySQL Setup – 2”.

1. MySQL client runs on the machine containing the databases and servers connect to the client over a network.
a) True
b) False
View Answer

Answer: b
Explanation: MySQL operates using a client/server architecture. It is the server that runs on the machine and not the client. The clients connect to the MySQL server to request information from the database(s).

2. The number of attributes in the following SQL table is ______________

CREATE TABLE employee (
		emp_name CHAR(30),
		emp_id INT

a) 30
b) 1
c) 2
d) 3
View Answer

Answer: c
Explanation: The name of the table created is ’employee’. It has two attributes, namely, ’emp_name’ and ’emp_id’. The attributes are the columns in a table. emp_name is of type string and emp_id is of type integer.

3. Which of the following options tells mysql to ask for entering the password?
a) -e
b) -p
c) -u
d) -h
View Answer

Answer: b
Explanation: The command ‘mysql -p’ (alternative form: –password) prompts for the password. ‘-h’ (alternative form: –host) specifies the host where the MySQL server is running. ‘-u’ is for specifying the username.
Note: Join free Sanfoundry classes at Telegram or Youtube

4. What is the host name in the following MySQL command?

mysql -h -p -u sampadam

a) cobra.snake
c) sampadam
d) cobra
View Answer

Answer: b
Explanation: The ‘-h’ option specifies the hostname of the server. The ‘’ is the complete host name. The ‘-p’ option prompts for the account’s password and ‘-u’ specifies the user name.

5. What is ‘tamp’ in the following MySQL command?

mysql -h -p -u tamp

a) user name
b) password
c) host name
d) table name
View Answer

Answer: a
Explanation: ‘tamp’ is the name of the user. The user will be prompted for password due to the ‘-p’ option. ‘’ is the host name here. The entire command specifies the host-user pair and prompts for password to establish the connection.

6. The query ‘SELECT NOW()’ shows the current _____________
a) table
b) time only
c) date only
d) date and time
View Answer

Answer: d
Explanation: SELECT NOW() is an SQL query. It shows both the current date and the current time. It is generally displayed in the format ‘yyyy-mm-dd hh-mm-ss’. For example, 2009-04-21 11-51-36.

7. Suppose you want to select a database named ‘sampledb’ as the default database. Which of the following commands do you use?
c) USE DATABASE sampledb
d) USE sampledb
View Answer

Answer: d
Explanation: ‘USE sampledb’ selects sampledb as the default database. Initially, ‘SELECT DATABASE();’ command displays ‘NULL’, since no database is selected by default. The other two are not valid commands.

8. What does ‘abc’ & ‘xyz’ specify in the following SQL statement?

CREATE TABLE abc (xyz);

a) table name and column specs
b) column specs and table name
c) table name and number of columns
d) table name and number of rows
View Answer

Answer: a
Explanation: The ‘CREATE TABLE’ construct’s syntax is ‘CREATE TABLE tbl_name (column_specs)’. ‘tbl_name’ indicates the table name. ‘column_specs’ provides the specifications of the table attributes.

9. To see the table structure, which of the following SQL commands is issued?
a) DESCRIBE tbl_name
b) VIEW tbl_name
c) SELECT TABLE tbl_name
d) SELECT tbl_name
View Answer

Answer: a
Explanation: The ‘DESCRIBE’ command is issued to see the structure of the table ‘tbl_name’. It shows the structure in the format: Field-Type-Null-Key-Default-Extra. The ‘VIEW’ and ‘SELECT’ commands are used to see the contents of the table.

10. SHOW DATABASES lists the databases in the server to which you are connected.
a) True
b) False
View Answer

Answer: a
Explanation: The ‘SHOW DATABASES’ command is used to display the list of the databases that are being managed by the server to which connection is established. This list would vary from server to server.

Sanfoundry Global Education & Learning Series – MySQL Database.

To practice all areas of MySQL for Interviews, here is complete set of 1000+ Multiple Choice Questions and Answers.

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.