数据库语句高级应用之修改数据库兼容版本
数据库在项目开发中几乎是必不可少的元素,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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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











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

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

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())

According to news on July 24, Apple recently pushed the highly anticipated visionOS1.3RC version update to VisionPro headset users. This update marks Apple’s continued innovation and progress in the field of virtual reality. Although the official did not clearly disclose the specific content of this update, users generally expect it to include performance optimization, functional improvements, and bug fixes. The internal version number of this update is 21O771, 141 days have passed since the last update. However, due to caching issues with node server configurations in Apple's various regions, some users may experience delays in upgrades and updates. Apple recommends users to back up their data before installing updates to ensure information security. 1.VisionPro users can use the "

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:

In the field of folding screens, small folding screens are also loved by many young users due to their lightweight, portable, exquisite and compact fashion attributes. In the previous review of the Samsung Galaxy Z Fold6 large folding screen, I gave it a "more square and more AI" evaluation. The small folding screen released at the same time, Samsung Galaxy Z Flip 6, has also attracted much attention. So what will it be like? Today, let’s unlock this new fashion product together. "Light" design: The fashionable appearance on the fingertips is the same as Galaxy Z Fold 6. The Galaxy Z Flip 6 body adopts a square design. In the unfolded state, the fuselage is slender than the average candy bar machine. The front and rear are connected by a straight-sided middle frame, and the four R corners retain a rounded shape.

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.
