Oracle service_name vs database name I am reading about Oracle and I am confused with the two names: service_name and database name.  Do they both refer to the database name used while creating a database with the CREATE DATABASE xxxxxx command?

Can the service name be different from the database name? If yes, how do we map the service name to the database name on the server? Because as a client, we use the service name to connect to the database, how does the server map the service name to the database name?
SERVICE_NAMES specifies one or more names by which clients can connect to the instance. The instance registers its service names with the listener. When a client requests a service, the listener determines which instances offer the requested service and routes the client to the appropriate instance.

You can specify multiple service names in order to distinguish among different users of the same database. For example:

SERVICE_NAMES = sales.acme.com, widgetsales.acme.com


You can also use service names to identify a single service that is available from two different databases through the use of replication.

If you do not qualify the names in this parameter with a domain, Oracle qualifies them with the value of the DB_DOMAIN parameter. If DB_DOMAIN is not specified, then no domain will be applied to the non-qualified SERVICE_NAMES values.

DATABASE NAME is the name of the physical database structure. It is stored at the controlfile and datafile header. It is used to identify all physical structures that belong to the same database. It can be defined at install time. It is originally defined by the static instance parameter database_name, and it cannot be changed, and the only way to change it is by means of rebuilding the controlfile and resetting the log sequence.

To conclude, you can have a common name for both of them. However, you might need different service names to distinguish among different users of the same database.