How to know the current database you are in

This is a discussion on How to know the current database you are in within the MySQL Database forums, part of the Database Forums category; Verion: 5.0.45-community-nt What's the command for knowing the current database you are in. For example: ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-18-2007
Water Cooler v2
 
Posts: n/a
Default How to know the current database you are in

Verion: 5.0.45-community-nt

What's the command for knowing the current database you are in. For
example:

a) mysql> show databases;

outputs:
1. foo
2. test
3. mysql

b) mysql> use foo;
Database changed

Is there a function or a global variable that will tell me the current
database I am in?

I KNOW THAT THE 'STATUS' command will, but it also comes up with a lot
of other stuff. Is there, like, an alternative command that just tells
you the name of the current database?

Everytime I forget if I am in the right database, I do a 'use foo'
thing, and it reports 'Database changed' always, even if I am in the
same database, which I find somewhat irritating and also ignorant on
my part.

How do I know which database I am sitting inside. I tried looking up
the manual but couldn't find something like CUR_DB or CURRENT_DB or
some such thing.

Reply With Quote
  #2 (permalink)  
Old 10-18-2007
Water Cooler v2
 
Posts: n/a
Default Re: How to know the current database you are in

On Oct 18, 11:24 am, Water Cooler v2 <wtr_...@yahoo.com> wrote:
> Verion: 5.0.45-community-nt
>
> What's the command for knowing the current database you are in. For
> example:
>
> a) mysql> show databases;
>
> outputs:
> 1. foo
> 2. test
> 3. mysql
>
> b) mysql> use foo;
> Database changed
>
> Is there a function or a global variable that will tell me the current
> database I am in?
>
> I KNOW THAT THE 'STATUS' command will, but it also comes up with a lot
> of other stuff. Is there, like, an alternative command that just tells
> you the name of the current database?
>
> Everytime I forget if I am in the right database, I do a 'use foo'
> thing, and it reports 'Database changed' always, even if I am in the
> same database, which I find somewhat irritating and also ignorant on
> my part.
>
> How do I know which database I am sitting inside. I tried looking up
> the manual but couldn't find something like CUR_DB or CURRENT_DB or
> some such thing.





Sorry, feeling stupid about my question. Soon after I hit the 'Send'
button on the original post, I came accross the DATABASE() function in
the manual.

*RESOLVED*

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:40 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0