PartOne Flashcards
<span><span>What does SELECT INTO do?</span></span>
Run the query. Create the target table. Insert the result of the query into the target table. All data type will be copied except constraints, triggers and indexes.
Which is not allowed to specify the target column in an insert stmt?
- default constraint
- not null
- identity
Identity
What is CROSS JOIN?
It performs cartesian product of the 2 input table.m rows in T1. n rows in T2. Cross join will produce m x n rows.
Left join / Right join
ON and WHERE works differently.The preserved side will return all rows regardless.The ON side just matches rows from the unpreserved side to the preserved side
INLINE table function
The function returns a table.Different from VIEW, it accepts parameters.
<span><strong>CREATE FUNCTION</strong> dbo.authors<br></br> ( @au_lname VARCHAR(40) )<br></br> <strong>RETURNS TABLE</strong><br></br> <strong>RETURN</strong><br></br> <strong>SELECT</strong> au_id, au_fname, au_lname, city, state<br></br> <strong>FROM </strong>authors<br></br> <strong>WHERE </strong>au_lname = @au_lname</span>
What is CROSS APPLY?
Similar to inner join.Does not return left side if table expression returns a empty set.
When a primary key or unique constraint is defined, SQL Server create ______ automatically.
Unique index
What’s the precedence?EXCEPT UNION INTERSECT
INTERSECT precedes UNION & EXCEPTUNION & EXCEPT are equal
Window functions
OVER ([PARTITION BY clause][ORDER BY clause][ROW or RANGE clause] )
Derived table
SELECT FROM(Select from where…) as d1 WHERE…
Describe INDEXED VIEW
An unique clustered index is created on the view and the actual result of the view query are stored on disk
VIEW WITH SCHEMABINDING
Guarantees the underlying table structures cannot be altered w/o dropping the view.
VIEW WITH ENCRYPTION
Make it difficult to discover the SELECT text of the view
VIEW WITH VIEW_METADATA
Return metadata instead of the base table
VIEW WITH CHECK OPTION
Prevent any updates thru the view that would cause some rows to get values no longer satisfying a where clause of the view