【问题标题】:How to tell if a view has been created WITH CHECK OPTION in Sybase ASE如何判断是否在 Sybase ASE 中使用 CHECK OPTION 创建了视图
【发布时间】:2015-06-25 00:24:06
【问题描述】:

是否可以确定 Sybase ASE (v15.7) 中的现有视图是否具有WITH CHECK OPTION 子句?我创建了 2 个除该子句外相同的视图,并且所有系统表中的条目(例如sysobjectssyscommentssysprotects 等)对于两个视图似乎都是相同的。 exec sp_helptext 不显示子句。

在 MSSQL 中,sys.views 有一个 with_check_option 列,但似乎没有 ASE 的等效项。

在下面的示例中,WITH CHECK OPTION 子句完全按预期工作,即插入到check_test_2 失败,除非将visible 设置为Y。有没有办法确定哪些视图设置了WITH CHECK OPTION 子句?

示例代码:

use tempdb
go

if object_id('check_test') is not null drop table check_test
go
create table check_test (id int, visible char(1))
go

if object_id('check_test_1') is not null drop view check_test_1
go
create view check_test_1
as
select *
from check_test
where visible = 'Y'
go

if object_id('check_test_2') is not null drop view check_test_2
go
create view check_test_2
as
select *
from check_test
where visible = 'Y'
with check option
go

【问题讨论】:

    标签: sql sybase sap-ase


    【解决方案1】:

    看起来这是 Sybase ASE 12.5 到 16.0 中的一个错误,但可能会在某些服务包中发布(16.0 SP01、15.7 SP134 - 尚未确认)。

    http://scn.sap.com/thread/3713912

    解决方案是设置一些开关(200 = 优化前的打印树,3604 = 打印输出到客户端),然后从视图中select,并在输出中搜索CHECKOPT,因此对于示例中的问题:

    use tempdb
    go
    set switch on 200
    set switch on 3604
    set noexec on
    go
    select *
    from check_test_2
    go
    

    (相当大的)输出中的某处将是:

    ... root2stat:(0x10000000 (BCP_LABELS, CHECKOPT)) ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-16
      • 2014-03-03
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-29
      相关资源
      最近更新 更多