如何判断视图是否已在 Sybase ASE 中使用 CHECK OPTION 创建
How to tell if a view has been created WITH CHECK OPTION in Sybase ASE
是否可以确定Sybase ASE (v15.7) 中的现有视图是否具有WITH CHECK OPTION
子句?我创建了 2 个除了该子句之外完全相同的视图,并且所有系统表中的条目(例如 sysobjects
、syscomments
、sysprotects
等)对于这两个视图来说似乎是相同的。 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
看起来这是 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)) ...
是否可以确定Sybase ASE (v15.7) 中的现有视图是否具有WITH CHECK OPTION
子句?我创建了 2 个除了该子句之外完全相同的视图,并且所有系统表中的条目(例如 sysobjects
、syscomments
、sysprotects
等)对于这两个视图来说似乎是相同的。 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
看起来这是 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)) ...