Vidyalelo
MySQL · Q247

MySQL

Programming · MySQL · question 247

Q247

How would a stored function named PI() written in the database 'sampdb' be called?

A.
PI()
B.
sampdb.PI()
Answer
C.
MySQL.PI()
D.
db.PI()

Answer: Option B

Solution

Answer: Option B
Solution:
This question asks how you call a stored function named PI() that's stored in the database sampdb.

Here's how to understand the options:
Option A: PI()
This would try to call a function named PI() in the current database you're connected to, not necessarily sampdb.
Option B: sampdb.PI()
This is the correct way to call the function. You specify the database name (sampdb) followed by a dot (.) and then the function name (PI()).
Option C: MySQL.PI()
This would try to call a function named PI() within the MySQL system database, which is unlikely where your function is stored.
Option D: db.PI()
This is incorrect because "db" isn't a recognized database name in this scenario.

Therefore, the correct answer is Option B: sampdb.PI()