数据库语句高级应用之修改数据库兼容版本
数据库在项目开发中几乎是必不可少的元素,sql Server 相信大家都特别熟悉吧,那么是否遇到过这样一个问题呢: 在分析数据库或者部署数据库的时候,出现了数据库不兼容的问题。 修改数据库兼容版本 语法 ALTER DATABASE database_name SET COMPATIBILITY_LEV
数据库在项目开发中几乎是必不可少的元素,香港服务器,sql Server 相信大家都特别熟悉吧,那么是否遇到过这样一个问题呢:
在分析数据库或者部署数据库的时候,出现了数据库不兼容的问题。
修改数据库兼容版本
语法
ALTER DATABASE database_name
SET COMPATIBILITY_LEVEL = { 80 | 90 | 100 |110 }
参数
database_name
要修改的数据库的名称。
COMPATIBILITY_LEVEL { 80 | 90 | 100 |110}
要使数据库与之兼容的 SQL Server 版本。该值必须为下列值之一:
= SQL Server 2000
= SQL Server 2005
= SQL Server 2008
= SQL Server 2012
备注
对于所有 SQL Server 2012 安装,美国服务器,默认的兼容级别都为 110。除非 model 数据库有更低的兼容级别,否则 SQL Server 2012 中创建的数据库会设置为该级别。将数据库从 SQL Server 的任何早期版本升级到 SQL Server 2012 时,如果数据库的兼容级别不在 80 以下,则该数据库将保留其现有的兼容级别。升级兼容级别低于 80 的数据库会将数据库的兼容级别设置为 80。这既适用于系统数据库,也适用于用户数据库。使用 ALTER DATABASE 可更改数据库的兼容级别。若要查看数据库的当前兼容级别,请查询 sys.databases 目录视图中的 compatibility_level 列。
利用兼容级别获得向后兼容
兼容级别只影响指定数据库的行为,而不影响整个服务器的行为。兼容级别只实现与 SQL Server 的早期版本保持部分向后兼容。通过将兼容级别用作临时性的迁移辅助工具,可解决相关兼容级别设置控制的行为之间存在的版本差异问题。如果现有 SQL Server 应用程序受到 SQL Server 2012 中行为差异的影响,请对该应用程序进行转换,使之能正常运行。然后使用 ALTER DATABASE 将兼容级别更改为 110。数据库的新兼容性设置将在该数据库下次成为当前数据库(无论是在登录时作为默认数据库还是在 USE 语句中指定)时生效。
最佳实践
如果在用户连接到数据库时更改兼容级别,可能会使活动查询产生不正确的结果集。例如,如果在编写查询计划时兼容级别发生更改,则编写后的计划可能同时基于旧的和新的兼容级别,从而造成计划不正确,香港空间,并可能导致结果不准确。此外,如果将计划放在计划缓存中供后续的查询重用,则问题可能更加复杂。为了避免查询结果不准确,建议您使用以下过程来更改数据库的兼容级别:
. 通过使用 ALTER DATABASE SET SINGLE_USER,将数据库设置为单用户访问模式。
. 更改数据库的兼容级别。
. 通过使用 ALTER DATABASE SET MULTI_USER,将数据库设为多用户访问模式。
有关设置数据库访问模式的详细信息,请参阅 ALTER DATABASE (Transact-SQL)。
name ,compatibility_level ,recovery_model_desc FROM sys.databases WITH(NOLOCK) test SET SINGLE_USER TEST sp_dbcmptlevel TEST, 90; test SET MULTI_USER
语法
sp_dbcmptlevel [ [ @dbname = ] name ]
[ , [ @new_cmptlevel = ] version ]
参数
[ @dbname = ] name
要为其更改兼容级别的数据库的名称。数据库名称必须符合标识符的规则。name 的数据类型为 sysname,默认值为 NULL。
[ @new_cmptlevel = ] version
数据库要与之兼容的 SQL Server 的版本。version 的数据类型为 tinyint,默认值为 NULL。该值必须为下列值之一:
= SQL Server 2000
= SQL Server 2005
= SQL Server 2008
= SQL Server 2012
返回代码值
(成功)或 1(失败)
结果集
如果未指定任何参数或未指定 name 参数,则 sp_dbcmptlevel 将返回错误。
如果指定 name 但未指定 version,则 数据库引擎将返回一条消息,显示指定数据库的当前兼容级别。
备注
有关兼容级别的说明,请参阅 ALTER DATABASE 兼容级别 (Transact-SQL)。
权限
只有数据库所有者、sysadmin 固定服务器角色和 db_owner 固定数据库角色的成员(前提是您要更改当前数据库)才能执行此过程。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

1. First open DingTalk. 2. Open the group chat and click the three dots in the upper right corner. 3. Find my nickname in this group. 4. Click to enter to modify and save.

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Regarding Llama3, new test results have been released - the large model evaluation community LMSYS released a large model ranking list. Llama3 ranked fifth, and tied for first place with GPT-4 in the English category. The picture is different from other benchmarks. This list is based on one-on-one battles between models, and the evaluators from all over the network make their own propositions and scores. In the end, Llama3 ranked fifth on the list, followed by three different versions of GPT-4 and Claude3 Super Cup Opus. In the English single list, Llama3 overtook Claude and tied with GPT-4. Regarding this result, Meta’s chief scientist LeCun was very happy and forwarded the tweet and

When publishing products on the Xianyu platform, users can customize the geographical location information of the product according to the actual situation, so that potential buyers can more accurately grasp the specific location of the product. Once the product is successfully put on the shelves, there is no need to worry if the seller's location changes. The Xianyu platform provides a flexible and convenient modification function. So when we want to modify the address of a published product, how do we modify it? This tutorial guide will provide you with a detailed step-by-step guide. I hope it can help. Everyone! How to modify the release product address in Xianyu? 1. Open Xianyu, click on what I published, select the product, and click Edit. 2. Click the positioning icon and select the address you want to set.

1. Open the Douyin app and click [Me] in the lower right corner to enter the personal page. 2. Click the [Three Stripes] icon in the upper right corner and select the [Settings] option in the pop-up menu bar. 3. In the settings page, scroll to the bottom to view the current version number information of Douyin.

There are currently 4 versions of World of Warcraft. The national server has been closed for more than a year. It is estimated that many players do not know where each version has developed. Let's sort out the current status of each version. 1. At the end of the official server version 10.0, before the closure of the national server, version 10.0 has just started. It is currently in version 10.26. There will be version 10.27 later, and the Age of Dragon expansion pack will be over. Although version 10.0 has received good reviews in foreign servers and has restored some popularity for Blizzard, the core of the game in version 10.0 has not changed at all. It is still mainly about big secrets and raids, and the number of PVP players is very small. With the continuous updates of the official server version, players’ gaming tendencies have also changed from PVE and PVP to collecting.

Many users are considering upgrading to the Windows 10 operating system. As Microsoft announced that it will no longer provide security updates and technical support for Windows 7. However, a considerable number of users still choose to stick to the Win7 system and look for office software suitable for this system. To help users improve office efficiency, this article will introduce several Office versions that are most suitable for Win7 systems. 1.Office2010: the perfect combination of stability and compatibility 2.Office2013: interface optimization and practical function upgrades 3.Office2016: new features of cross-platform collaboration and cloud storage 4.OfficeOnline: lightweight, free, online office anytime and anywhere 5 .WPSOffice:

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())
