大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
小编给大家分享一下如何解决sql server:alter database name的问题,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
创新互联服务项目包括福海网站建设、福海网站制作、福海网页制作以及福海网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,福海网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到福海省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
--step 1 : 修改数据库名称 USE master GO ALTER DATABASE GeovinDuCms SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO EXEC master..sp_renamedb 'GeovinDuCms','DuCms' GO ALTER DATABASE DB_SHANGHAI SET MULTI_USER GO --step 2 : 查看修改名称后的数据库逻辑名及物理文件名 USE master GO SELECT name AS [Logical Name], physical_name AS [DB File Path],type_desc AS [File Type], state_desc AS [State] FROM sys.master_files WHERE database_id = DB_ID(N'DuCms') GO --step 3 : 修改数据库逻辑文件名称 USE master GO ALTER DATABASE DuCms SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE DuCms MODIFY FILE (NAME=N'GeovinDuCms', NEWNAME=N'DuCms') GO ALTER DATABASE DuCms MODIFY FILE (NAME=N'GeovinDuCms_log', NEWNAME=N'DuCms_log') GO ALTER DATABASE DuCms SET MULTI_USER GO --step 4 : 修改数据库物理文件名称之前先打开xp_cmdshell支持 USE master GO sp_configure 'show advanced options',1 GO RECONFIGURE WITH OVERRIDE GO sp_configure 'xp_cmdshell', 1 GO RECONFIGURE WITH OVERRIDE GO --step 5 : 重命名数据库物理文件名称 USE [master] GO ALTER DATABASE DuCMS SET OFFLINE WITH ROLLBACK IMMEDIATE GO EXEC xp_cmdshell 'RENAME "E:\2005database\GeovinDuCms.mdf", "DuCms.mdf"' GO EXEC xp_cmdshell 'RENAME "E:\2005database\GeovinDuCms_log.ldf", "DuCms_log.ldf"' GO --step 6 : 将数据库逻辑名称指向新的物理文件,并将数据库online USE [master] GO ALTER DATABASE DuCMS MODIFY FILE (NAME =DuCms, FILENAME = 'E:\2005database\DuCms.mdf') GO ALTER DATABASE DuCMS MODIFY FILE (NAME =DuCms_log, FILENAME = 'E:\2005database\DuCms_log.ldf') GO ALTER DATABASE DuCMS SET ONLINE --step 7 : 查看全部修改完成后的数据库情况 USE master GO SELECT name AS [Logical Name], physical_name AS [DB File Path],type_desc AS [File Type], state_desc AS [State] FROM sys.master_files WHERE database_id = DB_ID(N'DuCMS') GO --step 8 : 关闭xp_cmdshell支持 USE master GO sp_configure 'xp_cmdshell', 0 GO RECONFIGURE WITH OVERRIDE GO sp_configure 'show advanced options',0 GO RECONFIGURE WITH OVERRIDE GO USE DuCMS GO
看完了这篇文章,相信你对“如何解决sql server:alter database name的问题”有了一定的了解,如果想了解更多相关知识,欢迎关注创新互联行业资讯频道,感谢各位的阅读!