SQL Server/T-SQL/Database/Database Option
Содержание
- 1 ANSI null default - "True" ensures SQL Server follows the SQL 92 rules to see if a column can allow NULL values
- 2 autoclose: "True" ensures that the resources are cleared when the last user logs off
- 3 autoshrink: "True" indicates this database can be shrunk in size safely
- 4 dbo use: "True" means that only the user ID that created the database has access and can use the database. Any other ID will be refused
- 5 quoted identifier - "True" ensure only single quotes are allowed when using this database
- 6 read only: "True" ensures no modifications to the data can be made. Only data reads are allowed
- 7 single: "True" ensures only one user has access to the database at a time. Any subsequent users will be refused
ANSI null default - "True" ensures SQL Server follows the SQL 92 rules to see if a column can allow NULL values
<source lang="sql">
1> 2> --ANSI null default - "True" ensures SQL Server follows the SQL 92 rules to see if a column can allow NULL values. 3> 4> CREATE DATABASE myDatabase 5> EXEC sp_dboption "myDatabase", "ANSI null default", "False" 6> GO 1> 2> Drop database myDatabase 3> GO 1>
</source>
autoclose: "True" ensures that the resources are cleared when the last user logs off
<source lang="sql">
1> 2> --autoclose: "True" ensures that the resources are cleared when the last user logs off. 3> 4> CREATE DATABASE myDatabase 5> 6> EXEC sp_dboption "myDatabase", "autoclose", "True" 7> GO 1> 2> Drop database myDatabase 3> GO
</source>
autoshrink: "True" indicates this database can be shrunk in size safely
<source lang="sql">
1> --autoshrink: "True" indicates this database can be shrunk in size safely. 2> CREATE DATABASE myDatabase; 3> EXEC sp_dboption "myDatabase", "autoshrink", "False" 4> GO 1> 2> Drop database myDatabase 3> GO 1>
</source>
dbo use: "True" means that only the user ID that created the database has access and can use the database. Any other ID will be refused
<source lang="sql">
1> --dbo use: "True" means that only the user ID that created the database has access and can use the database. Any other ID will be refused. 2> 3> CREATE DATABASE myDatabase 4> EXEC sp_dboption "myDatabase", "dbo use", "False" 5> GO 1> 2> Drop database myDatabase 3> GO 1>
</source>
quoted identifier - "True" ensure only single quotes are allowed when using this database
<source lang="sql">
1> 2> -- quoted identifier - "True" ensure only single quotes are allowed when using this database. 3> 4> --By setting this to OFF, you can delimit a string by either a single quote or a double quote. 5> 6> CREATE DATABASE myDatabase; 7> 8> EXEC sp_dboption "myDatabase", "quoted identifier", "True" 9> GO 1> 2> Drop database myDatabase 3> GO
</source>
read only: "True" ensures no modifications to the data can be made. Only data reads are allowed
<source lang="sql">
1> --read only: "True" ensures no modifications to the data can be made. Only data reads are allowed. 2> 3> CREATE DATABASE myDatabase 4> EXEC sp_dboption "myDatabase", "read only", "False" 5> GO 1> 2> Drop database myDatabase 3> GO 1>
</source>
single: "True" ensures only one user has access to the database at a time. Any subsequent users will be refused
<source lang="sql">
1> --single: "True" ensures only one user has access to the database at a time. Any subsequent users will be refused. 2> 3> CREATE DATABASE myDatabase 4> EXEC sp_dboption "myDatabase", "single", "False" 5> GO 1> 2> Drop database myDatabase 3> GO 1>
</source>