如何删除sys.objects中的对象 [英] How do I delete an object in sys.objects
问题描述
Hi
Hi
USE [MYDATABASE]
GO
select * from sys.objects
GO
I上面运行这个查询来获取我的数据库中的所有对象,然后我找到了一个给我带来麻烦的表。
我想在sys.objects中删除这个表object_id
I ran this query above to get all object in my DB, then I found a table that is giving me troubles.
I want to delete this table in sys.objects using object_id
USE [MYDATABASE]
GO
DELETE FROM sys.objects
WHERE object_id=245575913
GO</pre>
但我收到错误:
but I get error:
Msg 259, Level 16, State 1, Line 2
Ad hoc updates to system catalogs are not allowed.
当我从EF中的模型生成数据库时,问题就开始了,我手动删除了表,它就消失了。但是,当我尝试再次从模型生成数据库时,它给了我一个错误,导致我到那个表和一些外键。那就是那些我决定搜索sys.objects
如何删除此表?
The problem started when I was generating a database from a model in EF, I deleted the table manually and it disappeared. But when I tried to generate the database from model again it gave me an error that leads me to that table and some foreign keys. So thats thats were I decided to search the sys.objects
How can I remove this table?
推荐答案
您无法直接更新系统目录。要从sys.objects
目录中删除对象,请删除该对象:
You cannot update the system catalogs directly. To remove an object from thesys.objects
catalog, drop the object:
DROP TABLE TheTableToDrop
如果检查sys.objects在表中,您将看到其中一列具有类型名称。例如,CHECK_CONSTRAINT。然后,您可以调用:DROP CONSTRAINT [NAME]
您可以根据类型说明删除或更改它。
祝你好运!
If you check the sys.objects table you will see that one of the columns has the type name. For example, CHECK_CONSTRAINT. You can then call:DROP CONSTRAINT [NAME]
You can drop or change it according to the type description.
Good luck!
这篇关于如何删除sys.objects中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!