- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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)
- Related Articles
- Create a stored procedure to get the detail of a particular MySQL table stored in a database?
- Implement Conditional MySQL Query in a stored procedure?
- Implement Dynamic SQL query inside a MySQL stored procedure?
- Implement DELETE query in MySQL stored procedure
- Display table records from a stored procedure in MySQL
- How can a MySQL stored procedure call another MySQL stored procedure inside it?
- How can we use a MySQL stored function in a database query?
- Use IN() to get only a particular record in a MySQL stored procedure?
- How to get field name types from a MySQL database?
- MySQL Sum Query with IF Condition using Stored Procedure
- Set conditions in a MySQL stored procedure
- Create a MySQL stored procedure, which takes the name of the database as its parameter, to list the tables with detailed information in a particular database.
- How to create a Stored procedure in a database using JDBC API?
- Create a stored procedure with delimiter in MySQL
- Perform mathematical operations in a MySQL Stored Procedure?

Advertisements