根据同一表中其他列的值维护一个列。

时间:2022-02-04 13:17:24

In student table what is the query to create a default constraint on the column address as the value should get updated automatically based on the data of City+''+street+''+HouseNo.

在student表中,在列地址上创建默认约束的查询是什么,因为该值应该根据City+“+street+”+HouseNo的数据自动更新。

1 个解决方案

#1


2  

Well if the column is based on the values in other columns then I would not create that new column at all as it would be redundant. Construct the value when you query the table.

如果列是基于其他列中的值那么我就不会创建新的列,因为它是多余的。在查询表时构造值。

You could look into virtual columns as a means for ensuring that the definition of the constructed value is consistent and that it could be indexed, however. http://docs.oracle.com/cd/B28359_01/server.111/b28279/chapter1.htm#FEATURENO07254

您可以将虚拟列作为一种方法,以确保构造值的定义是一致的,并且可以对其进行索引。http://docs.oracle.com/cd/B28359_01/server.111/b28279/chapter1.htm FEATURENO07254

#1


2  

Well if the column is based on the values in other columns then I would not create that new column at all as it would be redundant. Construct the value when you query the table.

如果列是基于其他列中的值那么我就不会创建新的列,因为它是多余的。在查询表时构造值。

You could look into virtual columns as a means for ensuring that the definition of the constructed value is consistent and that it could be indexed, however. http://docs.oracle.com/cd/B28359_01/server.111/b28279/chapter1.htm#FEATURENO07254

您可以将虚拟列作为一种方法,以确保构造值的定义是一致的,并且可以对其进行索引。http://docs.oracle.com/cd/B28359_01/server.111/b28279/chapter1.htm FEATURENO07254