Hi,
I want to know what is the relation between view and Sequence in database?
Regards,
Printable View
Hi,
I want to know what is the relation between view and Sequence in database?
Regards,
Both are not related at all. A sequence is a database object that you can use to generate new values in, well, sequence. A sequence is not tied to any table or view. You can use the values from a sequence for whatever you like.
A view is exactly what its name implies: a (different) view on the data in your database. A view can be created on tables or other views and it essentially encapsulates a query, including joins, subselects, olap functions, ... - whatever DB2 (or SQL in general) lets you do in a query.
a sequence is a function whose domain is the set of positive integers
while a series is just a succession of separate numbers which is formed according to some rule or law
that means that a sequence must be a function (look at you're algebra 2 notes to define that one) and consists of a set of positive integer terms while a series doesn't have to be a function and is not confined as far as its input (not technically referred to as domain in this case because a series is not a function)
that is why one can equate the sum of a series because a series itself is not "a sum of numbers" but it is a good question math semantics always have their place in discussions/arguments
The similarity is that both are sort of "virtual tables", i.e., not physically stored but their data is "generated" when they are interrogated.
Apart from that, not much similarity.
If by "relation" you mean: use one in the definition of the other:
it is *not* possible to define a view where one column contains all values ever generated by a sequence. If that's what you want, you have to "materialize" those values, i.e., create a table, not a view.
And if that's all the sequence would be used for, then an identity column would be the more appropriate thing to use.
A view is a logical table based on a table or another view.
A view contain no data itself but it is like a window through which data from tables can be views and changed.
A sequence is a user created database object that can be
shared by multiple user to generate unique integers.