恢复的数据库缺少视图、存储过程和外键 [英] Restored database missing views, stored procs and foreign keys

查看:44
本文介绍了恢复的数据库缺少视图、存储过程和外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用备份-还原在 SQL Management Studio (SQL Server Express) 中创建数据库副本.本地到本地.当我这样做时,它会复制表和数据,但会忽略视图、存储过程和外键.

I'm trying to create a copy of a database in SQL Management Studio (SQL Server Express) using Backup-Restore. Local to local. When I do it it copies tables and data, but ignores views, stored procedures and foreign keys.

对象资源管理器->写入-单击数据库"->恢复数据库..."->输入名称->选择来自"数据库->转到

Object Explorer -> write-click "Databases" -> "Restore Database..." -> put in a name -> select a "from" database -> go

这是生成的脚本:

RESTORE DATABASE [DbName_raw] 
FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Backup\DbName.bak.1' 
WITH  FILE = 1,
MOVE N'GeoDo' TO N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\DbName_raw.mdf',  
MOVE N'GeoDo_log' TO N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\DbName_raw_1.ldf',  
NOUNLOAD,  STATS = 10
GO

数据库出现在对象资源管理器中,但缺少视图、存储过程和外键.在向导的设置中看不到任何明显的东西.我错过了什么?

Database appears in Object Explorer but with views, stored procs ad foreign keys missing. Can't see anything obvious in the settings of the wizard. What am I missing?

推荐答案

这是因为旧的备份文件.我的印象是从数据库备份只会复制当前存在的内容,但事实证明备份来自数据库的快照.这些备份不包含丢失的视图、存储过程和外键.

This was because of an old backup file. I was under the impression that backing up from a database would just copy what was there currently, but it turns out that the backups come from snapshots taken of the database instead. Those backups did not contain the missing views, stored procedures and foreign keys.

这篇关于恢复的数据库缺少视图、存储过程和外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆