SQL中PERSISTED关键字

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')

 

 

 

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐