Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default schema in MySQL

Tags:

mysql

Thanks to the 'USE' command I can set the default schema; Is there a similar command in order to get the name of the default schema?

like image 460
Paul Avatar asked Sep 11 '11 12:09

Paul


2 Answers

SELECT DATABASE(); should do the trick. Note that this will return NULL if there is no schema currently selected.

like image 135
Michael Mior Avatar answered Sep 21 '22 00:09

Michael Mior


Mysql provides a function to do this:

SELECT database();
like image 35
shiying yu Avatar answered Sep 19 '22 00:09

shiying yu