C# 的持久 SQL 表锁

发布于 2024-09-04 12:55:48 字数 262 浏览 9 评论 0原文

我正在尝试在表级别创建持久 SQL (SQL Server 2005) 锁。我没有更新/查询指定的表,但我需要阻止第三方应用程序更新锁定的表,以此作为防止发布事务的方法(我希望锁定的表是其事务上干扰的关键)我的处理)。

根据我的经验,该表仅在特定事务发生时被锁定。有什么想法吗?

3rd 方开发人员已将此功能记录为增强功能,但由于他们正在推出主要版本,因此我预计至少要等待 6 个月。我知道这不是一个很好的解决方案,因为他们的软件会崩溃,但它的性质足够重要,我们愿意承担后果。

I'm trying to create a persistent SQL (SQL Server 2005) lock on a table level. I'm not updating/querying the specified table, but I need to prevent a third party application from updating the locked table as a means to prevent transactions from being posted (the table I wish to lock is the key on their transaction that interferes with my processing).

From my experience the table is only locked for the time a specific transaction is taking place. Any ideas?

The 3rd party developer has logged this feature as an enhancement, but since they are in the middle of rolling out a major release I can expect to wait at least 6 months for this. I know that this isn't a great solution, since their software will fall over but it is of a critical enough nature that we're willing to live with the consequences.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷清清 2024-09-11 12:55:48

将表移动到不同的文件组,然后将该文件组更改为只读。该表实际上是只读的:

ALTER DATABASE dbName 
   ADD FILEGROUP ReadOnlyFG;
GO

ALTER DATABASE dbName 
   ADD FILE (
    NAME = ...,
    FILENAME = '...')
   TO FILEGROUP ReadOnlyFG;
GO

ALTER TABLE tableName MOVE TO ReadOnlyFG;
GO

ALTER DATABASE dbName
   MODIFY FILEGROUP ReadOnlyFG READONLY;

Move the table to a different file group, then alter the file group to read-only. The table will be in effect read-only:

ALTER DATABASE dbName 
   ADD FILEGROUP ReadOnlyFG;
GO

ALTER DATABASE dbName 
   ADD FILE (
    NAME = ...,
    FILENAME = '...')
   TO FILEGROUP ReadOnlyFG;
GO

ALTER TABLE tableName MOVE TO ReadOnlyFG;
GO

ALTER DATABASE dbName
   MODIFY FILEGROUP ReadOnlyFG READONLY;
青萝楚歌 2024-09-11 12:55:48

重命名该表,当第 3 方准备就绪时,将其重命名回应有的名称

rename the table and when the 3rd party is ready rename it back to what it should be

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文