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

 

相关文章:

  • 2022-01-06
  • 2021-08-26
  • 2022-02-17
猜你喜欢
  • 2021-09-27
  • 2021-09-06
  • 2022-12-23
  • 2021-05-18
  • 2021-08-21
  • 2022-12-23
  • 2021-10-17
相关资源
相似解决方案