当前位置: 移动技术网 > IT编程>数据库>MSSQL > SQL中PERSISTED关键字

SQL中PERSISTED关键字

2019年04月30日  | 移动技术网IT编程  | 我要评论

狂暑季,百变大咖秀20130207,还我河山1929

sql中persisted关键字

 

persisted 

指定 sql server 引擎将在表中物理存储计算值,而且,当计算列依赖的任何其他列发生更新时对这些计算值进行更新。将计算列标记为 persisted,可允许您对具有确定性、但不精确的计算列创建索引。有关详细信息,请参阅为计算列创建索引。用作已分区表的分区依据列的所有计算列都必须显式标记为 persisted。指定 persisted 时,computed_column_expression 必须具有确定性。

create table orders
(
orderid int not null,
price money not null,
quantity int not null,
orderdate datetime not null,
total as price*quantity ,
total2 as price * quantity persisted,
shipedate as dateadd (day,7,orderdate)
)
insert into orders (orderid,price,quantity,orderdate) values (1,2,6,'2008-8-8')

 

 

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网