MySQL Questions and Answers – Interacting with MySQL

This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Interacting with MySQL”.

1. The command to move the cursor to the beginning of line in MySQL input editor is?
a) Ctrl-A
b) Ctrl-E
c) Ctrl-D
d) Esc-a
View Answer

Answer: a
Explanation: Control-A moves the cursor to the beginning of the line. Ctrl-E moves the cursor to the end of the line. Control-D deletes the character under the cursor whereas Esc-a is not valid.

2. What does Control-_ do in MySQL input editor?
a) copies to clipboard
b) pastes from clipboard
c) undoes last change
d) deletes the current line
View Answer

Answer: c
Explanation: Control-_ undoes the last change that was made. This can be repeated. The mysql input editor has a variety of commands to facilitate editing while providing inputs to the command line itself.

3. On UNIX, statements entered in ‘MySQL’ are saved in which file?
a) .mysql_queries
b) .queries
c) .mysql_history
d) .history
View Answer

Answer: c
Explanation: Statements entered in ‘MySQL’ are stored in the file named ‘.mysql_history’. This file is located in the home directory itself. The SQL statements can be directly pasted into this file.
advertisement
advertisement

4. MySQL can be used to execute script files.
a) True
b) False
View Answer

Answer: a
Explanation: MySQL is capable of reading input from a file in batch mode. This is also known as the non-interactive mode. A lot of typing and time can be saved when commands are stored in a file and executed from a file.

5. Suppose run_me.sh is a script file. Which command is used to make it executable?
a) chmod +e run_me.sh
b) chmod +a run_me.sh
c) chmod +y run_me.sh
d) chmod +x run_me.sh
View Answer

Answer: d
Explanation: The command ‘chmod +x file_name’ makes a script file executable. mysql supports reading from a script file and executing queries from it. Before a script is run, it is necessary for it to be made executable.

6. To execute the contents of a query file ‘exec.sql’ by feeding it to mysql, which command is used?
a) mysql exec.sql > sampdb
b) mysql sampdb < exec.sql
c) mysql exec.sql
d) mysql exec
View Answer

Answer: b
Explanation: mysql queries can be run after placing the queries in a file, and then executing it by feeding it to mysql. By default, mysql prints output in a tab-delimited format when it is running in noninteractive mode.

7. Which option prints output in table-format when MySQL is run interactively?
a) -t
b) -tf
c) -p
d) -pf
View Answer

Answer: a
Explanation: MySQL produces output in tab-delimited format when it is run in batch mode. Suppose a table-format output is desired, the -t option is used along with the mysql command. -tf is not a valid option.
advertisement

8. The clause that enables mapping a short command to a long command is __________
a) map
b) direct
c) label
d) alias
View Answer

Answer: d
Explanation: If the shell program permits an alias, a short command can be mapped to a long command. This reduces the time taken by typing long commands frequently. An alias is defined by the keyword ‘alias’ followed by the short and long commands.

9. The connection parameters for setting up MySQL can be stored in an option file to save typing the names every time a connection is established.
a) True
b) False
View Answer

Answer: a
Explanation: Every Time MySQL is invoked, connection parameters like hostname, username and password are required. To save typing these parameters all the time, they can be saved in an option file instead and executed when setting up the connection.
advertisement

10. In UNIX, the name of the option file is __________
a) .my.cnf
b) .my.ini
c) .my.opt
d) .my.opc
View Answer

Answer: a
Explanation: Under Unix, an option file is set up by creating a file named ‘~/.my.cnf’ in the home directory. ‘C:\my.ini’ is the option file that is setup in Windows. An option file stores the connection parameters.

Sanfoundry Global Education & Learning Series – MySQL Database.

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

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
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.