sci (sc****@yahoo.com) writes:
What's "result set"?
Lyndon Hills has already explained this, but permit me to elaborate.
The theory behind relational databases are based on set theory. A table
is a unordered set of data. Thus, the result of a query is also a
table in the logical sense, or a set if you like.
What's "set-based statement"?
A statement which operates on many rows at a time.
Why "set-based statement" is faster than cursor?
I like to supplement Lyndon's answer. He said that tables are fast
because they are indexed, and that is true. However, set-based
statements are faster even if there is no useful index. Say that
we want increaese the salary for all employees with 2%. This can
be done with:
UPDATE employees SET salary = salary * 1.02
The alternative to a set-based statement would be to set up a cursor
and update one row at a time. This would be a lot slower, because there
is a certain overhead to locate a row.
And, as Lyndon so well said: because set-based is what relational
engines are designed for.
Since we call a view a pre-packaged query, does this mean that we can
constructed a view and save it in a database for it to be used in a query?
Can a view be either constructed from one table or multiple tables?
A view can be a query that includes many tables - or other views for
that matter. And, yes, a view can be saved in the database for later
queries.
Is a view always to be used in a query, or can it be used somewhere else?
About anything in a database is being used in a query one way or another.
You don't put data in a database, unless you intended to query it in
some way or another.
Normally, you construct views to give users easier access to data. Not
all systems have views, though. The system I work with does not, for
instance. This is because our users access the database from a GUI,
and do not access the database directly.
--
Erland Sommarskog, SQL Server MVP,
so****@algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp