- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get database name from a query implemented in a MySQL Stored Procedure?
To get the database name, use the below given syntax −
select database();
Let us implement the above syntax in the stored procedure −
mysql> delimiter // mysql> create procedure get_procedure_database_name() -> begin -> select concat('The database name=',database()); -> end -> // Query OK, 0 rows affected (0.34 sec) mysql> delimiter ;
Now you can call a stored procedure using CALL command −
mysql> call get_procedure_database_name();
This will produce the following output −
+-----------------------------------------+ | concat('The database name=',database()) | +-----------------------------------------+ | The database name=web | +-----------------------------------------+ 1 row in set (0.05 sec) Query OK, 0 rows affected (0.08 sec)
Advertisements