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?

Was it helpful?

Solution

Running the following code shows the default database on ASE:

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top