General Flashcards
transaction level isolation READ UNCOMMITTED
Transactions running at the READ UNCOMMITTED level do not issue shared locks to prevent other transactions from modifying data read by the current transaction. READ UNCOMMITTED transactions are also not blocked by exclusive locks that would prevent the current transaction from reading rows that have been modified but not committed by other transactions. When this option is set, it is possible to read uncommitted modifications, which are called dirty reads. Values in the data can be changed and rows can appear or disappear in the data set before the end of the transaction. This option has the same effect as setting NOLOCK on all tables in all SELECT statements in a transaction. This is the least restrictive of the isolation levels.
transaction level isolation READ COMMITTED
Specifies that statements cannot read data that has been modified but not committed by other transactions. This prevents dirty reads. Data can be changed by other transactions between individual statements within the current transaction, resulting in nonrepeatable reads or phantom data. This option is the SQL Server default.
TRANSACTION ISOLATION LEVEL REPEATABLE READ
Specifies that statements cannot read data that has been modified but not yet committed by other transactions and that no other transactions can modify data that has been read by the current transaction until the current transaction completes.
TRANSACTION ISOLATION LEVEL SNAPSHOT
Specifies that data read by any statement in a transaction will be the transactionally consistent version of the data that existed at the start of the transaction. The transaction can only recognize data modifications that were committed before the start of the transaction. Data modifications made by other transactions after the start of the current transaction are not visible to statements executing in the current transaction. The effect is as if the statements in a transaction get a snapshot of the committed data as it existed at the start of the transaction.
TRANSACTION ISOLATION LEVEL SERIALIZABLE
- Statements cannot read data that has been modified but not yet committed by other transactions.
- No other transactions can modify data that has been read by the current transaction until the current transaction completes.
- Other transactions cannot insert new rows with key values that would fall in the range of keys read by any statements in the current transaction until the current transaction completes.
XML is case sensitive
True
How do you generate the XSD schema?
XMLSchema in the For XML Clause
What XML formats data like this:
For XML Raw
What XML formats data like this:
1
Customer A
123
345
For XML Auto, Elements (optional to make it element centric otherwise the items would be rolled up to combine all the elements of oen area like custid and companyname would be one element), Root (‘CustomersOrders’)
Also you can add With XMLNameSpaces(‘TK461-CustomersOrders’ as co) to the top above the Select to add the xmlso:co=”TK461-CustomersOrders”
Where do you place the For XML Auto?
After the Order By Clause
What is the order of execution?
FROM clause WHERE clause GROUP BY clause HAVING clause SELECT clause ORDER BY clause
How do you completely define the the elements in a created XML document?
Use XML Path
What does Persisted do?
Specifies that the Database Engine will physically store the computed values in the table, and update the values when any other columns on which the computed column depends are updated. Marking a computed column as PERSISTED allows an index to be created on a computed column that is deterministic, but not precise. For more information, see Indexes on Computed Columns. Any computed columns used as partitioning columns of a partitioned table must be explicitly marked PERSISTED. computed_column_expression must be deterministic when PERSISTED is specified.
How do you format a date into international datetimes for viewing?
Use the format function.
Returns a value formatted with the specified format and optional culture in SQL Server 2012. Use the FORMAT function for locale-aware formatting of date/time and number values as strings. For general data type conversions, use CAST or CONVERT.
FORMAT ( value, format [, culture ] )
Format can also be used to format strings and do things like add leading zeros.
How do you limit the data going into a field on a table to certain values?
Use a check constraint
Holdlock
Use a hold lock to hold a lock until completion of the transaction, instead of releasing the lock as soon as the required table, row, or data page is no longer required.
Rowlock
Use row-level locks when reading or modifying data.
xlock
Use exclusive locks instead of shared locks while reading a table, and use hold locks until the end of the statement or transaction.
UPDLOCK
UPDLOCK reads data without blocking other readers, and update it later with the assurance that the data has not changed since last read.
If an analysis of a query plan shows table cans where the estimated row do not match the actual rows in the query, what should you do?
Update the statistics on all the involved tables.
Updates query optimization statistics on a table or indexed view. By default, the query optimizer already updates statistics as necessary to improve the query plan; in some cases you can improve query performance by using UPDATE STATISTICS or the stored procedure sp_updatestats to update statistics more frequently than the default updates.
What types of table compression are available?
Page or Row
Page compression includes Row compression.
You add compression when creating or altering a table With (Data_Compression = Page or Row)
What does IAM stand for?
Index Allocation Map
What levels can an index have?
Root, leaf, intermediate
What tracks index usage?
dm_db_index_usage_stats
What does DM stand for?
Dynamic Management view or function
Dynamic management views and functions return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance.
How do you know there are no more rows to fetch?
@@fetch_status = -1
tablock
Use a table lock when reading or modifying data.
what are the mathematical branches that the relational model is based on?
Set theory and predicate logic
What is the difference between newid and newsequentialid?
NewID is a unique GUID, but there is no way of knowing the value returned. newsequentialid is also a unique GUID but for the machine and it is sequential.
What does Coalesce do?
It accepts a list of inputs and it returns the first one that is not null.
Coalsece (column1, column2, ‘nothing’)
What is the downside to Coalesce or isNull?
When used in the where clause they both cause a performance issue, since the index will not be used.
What function returns the current date and time value as a datetime2 type?
SysDateTime
When concatenating strings, what is the difference between + and the concat function?
The + operator returns a null if any of the values are null, the concat treats null as an empty string.