[英]Can we remove Memory Optimized file group from database
I checked In sql server 2019(15.0.2070.41) and tried to remove with bellow mentioned command:我检查了 sql server 2019(15.0.2070.41) 并尝试使用下面提到的命令删除:
Alter database InMemoryCheckpoint
Remove file InMemoryCheckpointDF
Alter database InMemoryCheckpoint
Remove filegroup InMemoryCheckpointDF
You can't remove a memory-optimized filegroup.您不能删除内存优化文件组。
The following limitations apply to a memory-optimized filegroup:
以下限制适用于内存优化文件组:
Once you use a memory-optimized filegroup, you can only remove it by dropping the database.
使用内存优化文件组后,只能通过删除数据库来删除它。 In a production environment, it is unlikely that you will need to remove the memory-optimized filegroup.
在生产环境中,您不太可能需要删除内存优化文件组。
https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/the-memory-optimized-filegroup?view=sql-server-ver15 https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/the-memory-optimized-filegroup?view=sql-server-ver15
1- Delete memory optimized tables 1- 删除 memory 优化表
2- Detach Database 2-分离数据库
3- Create new database with same files without memory optimized filegroup 3-创建具有相同文件的新数据库,但没有 memory 优化文件组
4- Modify database files and change it to detached database (mdf,ldf,ndf) files 4-修改数据库文件并将其更改为分离的数据库(mdf,ldf,ndf)文件
alter database test1 modify file (name='test1' , filename='C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\test.mdf')
alter database test1 modify file (name='test1_log' , filename='C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\test_log.ldf')
5- Now try to to repair database: 5-现在尝试修复数据库:
alter database test1 set emergency
alter database test1 set single_user with ROLLBACK IMMEDIATE;
dbcc checkdb(test1,repair_allow_data_loss)
alter database test1 set multi_user
alter database test1 set online
6- After successfully repair database remove memory optimized filegroup from database 6- 成功修复数据库后,从数据库中删除 memory 优化文件组
ALTER DATABASE [test1] REMOVE FILEGROUP [memory_optimized_filegroup_0]
Follow steps correctly for prevent log corruption
正确执行步骤以防止日志损坏
Step 4: Alter log file name must be done correctly Step 5: DBCC is Important to prevent corruption
第 4 步:必须正确更改日志文件名 第 5 步:DBCC 对防止损坏很重要
Also for getting best result:
也为了获得最佳结果:
Don't use database while doing steps (Insert - Update - Changing Schema)
执行步骤时不要使用数据库(插入 - 更新 - 更改架构)
do CHECKPOINT to flush log to data file then shrink log file
执行 CHECKPOINT 将日志刷新到数据文件,然后收缩日志文件
you will never have log corruption issue
你永远不会有日志损坏问题
Used these commands and they worked fine for me:使用了这些命令,它们对我来说很好用:
USE [<dbname>]
GO
ALTER DATABASE [<dbname>] REMOVE FILE [<filename>]
GO
ALTER DATABASE [<dbname>] REMOVE FILEGROUP [<Group Name>]
GO
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.