Why does SQL Server 2012 create separate default user databases?

When I create a database - it creates it as (one user):

  • Why is my default? Do I have this in my settings?
  • How to change an existing database from one to several?
+4
source share
2 answers

Whenever you create a new database, you get a copy of the model database, so it seems to you that your model database is installed on one user.

When the CREATE DATABASE statement is issued, the first part of the database is created by copying the contents of the model database. The rest of the new database is filled with blank pages.

If you modify the model database, all subsequently created databases inherit these changes. For example, you can set permissions or database parameters, or add objects such as tables, functions, or stored procedures.

(My emphasis)

To change the database for simultaneous use, run :

 ALTER DATABASE <dbName> set multi_user 

Replacing <dbName> with the database name to modify.

+9
source

TRY IT:

By default, it will be in multi-user mode.

Under certain circumstances, you may need to start an instance of SQL Server in single-user mode using the -m startup option. For example, you can change server configuration settings or repair a damaged primary database or other system database. Both steps require running an instance of SQL Server in single user mode.

To change a database from multiple users to one user:

 ALTER DATABASE TEST_DB SET SINGLE_USER WITH ROLLBACK IMMEDIATE; 

To change a database from one user to several users:

 ALTER DATABASE TEST_DB SET MULTI_USER WITH ROLLBACK IMMEDIATE; 
0
source

Source: https://habr.com/ru/post/1491582/


All Articles