What is the difference between database name and username?
42 Answers
What is the difference between database name and username?
This boils down to: What is the difference between database and user? Which makes me wonder: Do you expect a database and a user to be the same thing???
A database is mainly a collection of tables you store data in. You give it a name to indicate what it contains, e.g. MYBUSINESS containing a product table for the products you are selling in your webshop, a client table and what more.
Then there are people working with the database. The users. They log in with their user names, say TOMSMITH and MARYSMITH. Other people are not allowed to work with the database. They have no user name and cannot log in. And if a user changes a price, you can log this action in a table with the user name, so you know later who changed the price.
3The database name is the name of the database and the username is the name of the user that is connected to the database.
e.g. John Smith could connect to a database called Database1. Database1 would be the database name and John Smith would be the username.
If you are using Oracle you can use:
SELECT name FROM v$databases to get the DB Name
MySQL I think is SELECT Database()