Week 7 Flashcards
What is a view?
a view is a virtual table!!! basically making it virtually
CREATE VIEW view_name AS
SELECT column1, column2, …
FROM table_name
WHERE condition
you can do all the things!!! inner joins and all the others week 5 studd
What does isnull(__,0) function do?
replaces all null values with 0
wHAT IS a dynamic view
virtual table created dynamically base don user request
no data actuall stroed
instead data from base table is aavialbel for user
based on sql select statmeemtns on basee tabls or other views
Materialized view
Copy or replication of data
DATA IS ACTUALLY STORED
Must be regreshed periodically to match correpsonding base table
pros of dynamic views
simplify query commands
assist with data security
enhance programming productivity
contain most current base table data
use little stroage space
provide custom view for user
establsih physical data independance
cons of dynamic views
use processing time each time view is references
may/may not be directly updatebale
as with al sql constructs, you should use views with discretion
what is a routine
program modules that execute on demand
3 compeonents of a tourine
function: routines that return values and take input paramaeters
stored procedure: routines that do not return values and can take input or output parameters
triggers: routines that executive in response to a db event (insert, update, deletE)
what is a stored procedure
if you are repeating an excel query constantlty, you can save it as a stored proceudre and then call it or execute it
example of stored proceudre
CREATE PROCEDURE (name)
@parameter1 datatyp
@parameter2 datatype
AS —-
BEGIN
SQL statmeents
END
LIKE,,,,,,,,,,,,,,,,,,,,,,,
CREATE PROCEDURE SelectProduct AS
begin
SELECT * FROM Product_T;
end
how to execute a stroed proceduree
EXEC procedure naem
What is an index?
what is a clustered index
sort and store the data riws in the table or view based in their key values
CREATE INDEX index1 ON table1 (column1)
Nonclustered index
having a structure separate from the data rows
containing key values and each key value entry has a pointer to the data row that contains the key value
CREATE CLUSTERED INDEX index1 ON table1 (column1)
How do you access data dictionary in sql server
metadata in sql server cannot be queried directly, it is exposed in
CATALOG VIEWS
INFO SCHEMA VIEWS