下面是查询视图Aview的列信息是否是计算列:create table A
(a int )insert into A select 4;create view AView
as
select a-2 as 'b' from Aselect * from Aview
select name,is_computed from sys.columns where object_id=object_id('Aview')
定义视图Aview时列b是计算列,为什么查询后此列的is_computed属性为0而不是1?
想要判断视图中的列是否为计算列应如何判断?
(a int )insert into A select 4;create view AView
as
select a-2 as 'b' from Aselect * from Aview
select name,is_computed from sys.columns where object_id=object_id('Aview')
定义视图Aview时列b是计算列,为什么查询后此列的is_computed属性为0而不是1?
想要判断视图中的列是否为计算列应如何判断?
0 = 未计算。
1 = 已计算。
列名 数据类型 描述
name sysname 对象名。
Id int 对象标识号。
xtype char(2) 对象类型。可以是下列对象类型中的一种:
C = CHECK 约束
D = 默认值或 DEFAULT 约束
F = FOREIGN KEY 约束
L = 日志
FN = 标量函数
IF = 内嵌表函数
P = 存储过程
PK = PRIMARY KEY 约束(类型是 K)
RF = 复制筛选存储过程
S = 系统表
TF = 表函数
TR = 触发器
U = 用户表
UQ = UNIQUE 约束(类型是 K)
V = 视图
X = 扩展存储过程
uid smallint 所有者对象的用户 ID。
info smallint 保留。仅限内部使用。
status int 保留。仅限内部使用。
base_schema_ver int 保留。仅限内部使用。
replinfo int 保留。供复制使用。
parent_obj int 父对象的对象标识号(例如,对于触发器或约束,该标识号为表 ID)。
crdate datetime 对象的创建日期。
ftcatid smallint 为全文索引注册的所有用户表的全文目录标识符,对于没有注册的所有用户表则为 0。
schema_ver int 版本号,该版本号在每次表的架构更改时都增加。
stats_schema_ver int 保留。仅限内部使用。
type char(2) 对象类型。可以是下列值之一:
C = CHECK 约束
D = 默认值或 DEFAULT 约束
F = FOREIGN KEY 约束
FN = 标量函数
IF = 内嵌表函数
K = PRIMARY KEY 或 UNIQUE 约束
L = 日志
P = 存储过程
R = 规则
RF = 复制筛选存储过程
S = 系统表
TF = 表函数
TR = 触发器
U = 用户表
V = 视图
X = 扩展存储过程
userstat smallint 保留。
sysstat smallint 内部状态信息。
indexdel smallint 保留。
refdate datetime 留作以后使用。
version int 留作以后使用。
deltrig int 保留。
instrig int 保留。
updtrig int 保留。
seltrig int 保留。
category int 用于发布、约束和标识。
cache smallint 保留。
--查询数据库中的用户表名称
select name from sysobjects where xtype = 'U' order by name
/*
name
--------
authors
discounts
jobs
pub_info
publishers
roysched
sales
stores
Table1
Table2
titleauthor
titles
(所影响的行数为 12 行)
*/
--查询数据库中的视图名称
select name from sysobjects where xtype = 'V' order by name
/*
name
--------------
sysconstraints
syssegments
titleview
(所影响的行数为 3 行)
*/