How to see where the default database is configured for a particular username or login name?

dba.stackexchange https://dba.stackexchange.com/questions/161519

Question

Once I connect to a database server without specifying a particular database, e.g. with:

sqsh -Usomeuser -Ssomeserver

… I can do a:

select db_name();

… to see the default database for this user. But where is this information kept and / or how can I see the default databases configured for every user name or login name?

Était-ce utile?

La solution

Running the following code shows the default database on ASE:

SELECT sl.name
    , sl.dbname
FROM syslogins sl
ORDER BY sl.name;

Autres conseils

About default DB:

  • default DB per login is held in the master DB system table syslogins column dbname
  • this column is selectable by public group (everyone is in this group) i.e. select permission is granted to public
  • alternative is to execute the system stored procedure sp_displaylogin <loginname> to display the default DB

You can check access permissions using exec sp_helprotect syslogins within the context of master DB.

Licencié sous: CC-BY-SA avec attribution
Non affilié à dba.stackexchange
scroll top