Suppose you want to select a database named 'sampledb' as the default database. Which of the following commands do you use?
A. SELECT DATABASE()
B. SELECT DATABASE sampledb
C. USE DATABASE sampledb
D. USE sampledb
Answer: Option D
Solution (By Examveda Team)
This question is about how to tell MySQL which database you want to work with. Imagine you have multiple folders on your computer, and you want to work in a specific folder. In MySQL, you have different databases, and you need to choose the one you want to use.The command to do this is USE. So the correct answer is Option D: USE sampledb.
Let's break down the options:
* Option A: SELECT DATABASE() This command will tell you the currently selected database, but it won't change it.
* Option B: SELECT DATABASE sampledb This is incorrect syntax, and it wouldn't work.
* Option C: USE DATABASE sampledb This is close, but the DATABASE keyword is unnecessary.
* Option D: USE sampledb This is the correct way to switch to the 'sampledb' database.
Join The Discussion