Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
36 Cards in this Set
- Front
- Back
What are the categories of T-SQL Statements? |
Data Manipulation Language (DML) Data Definition Language (DDL) Data Control Language (DCL) |
|
Name the 4 types of T-SQL Data Manipulation Language Categories (Statements for querying and modifying data) |
Select Insert Update Delete |
|
What are the 3 Data Definition Language Categories (Statements for object definitions) |
Create Alter Drop |
|
What are the Data Control Language Categories? (Statements for security permissions) |
Grant Revoke Deny |
|
Name the 2 types of T-SQL Language Elements? |
Predicates Operators |
|
List the Predicates used in T-SQL queries. |
In Between Like |
|
Describe the difference in the Predicates 'IN', 'BETWEEN', and 'LIKE'. |
'In' is used to determine if a value matches any value in a list or subquery 'Between' is used to specify a range of values 'Like' is used to match characters against a pattern |
|
List the Comparison Operators used in T-SQL. |
=, >, <, >=, <=, <>, !=, !>, !< (equal, greater than, less than greater than or equal to, less than or equal to, not equal to...) |
|
What are the 3 Logical Operators in T-SQL? |
AND OR NOT |
|
List the Arithmetic Operators used in T-SQL. |
+, -, *, /, % (add, subtract, multiply, divide, and modulo) |
|
What symbol is used for Concatenation in T-SQL? |
+ (plus sign) |
|
What is the Order of Evaluation of T-SQL Operators? |
( ) Parentheses *,/% (multiply, divide, modulo) +,- (add/positive/concatenate, subtract/negative) =,<,>, >=, <=, !=,! >, !< (comparison) NOT AND BETWEEN, IN, LIKE, OR = (Assignment) |
|
Name the T-SQL Language Element Functions. |
String Functions Date and Time Functions Aggregate Functions Mathematical Functions |
|
Name the T-SQL String Functions. |
SUBSTRING LEFT, RIGHT LEN DATALENGTH REPLACE REPLICATE UPPER, LOWER, RTRIM, LTRIM |
|
What are the T-SQL Date and Time Functions? |
GETDATE SYSTDATETIME GETUTCDATE DATEADD DATEDIFF YEAR MONTH DAY |
|
Name the T-SQL Aggregate Functions one can use in a query. |
SUM MIN MAX AVG COUNT COUNTBIG |
|
Bonus: Name the T-SQL Mathematical Functions. |
RAND ROUND POWER ABS CEILING FLOOR |
|
What are Variables used for in T-SQL and give some characteristics of them? |
Temporarily store a value of a specific data type. It must be declared. It's local, not global. The name begins with a single @ sign. It is assigned a data type. |
|
What is the syntax for creating a Variable in T-SQL? |
DECLARE @MyVar int = 30; |
|
What are Expressions in T-SQL? |
Combination of identifiers, values, and operators evaluated to obtain a single result Can be used in SELECT statements and WHERE clauses. SELECT=manipulate columns CASE=to replace values matching a logical expression with another value WHERE=filtering As Table Expressions to create temp sets for further processing |
|
Name some commonly-used control-of-flow, errors, and transaction statements. |
IF...ELSE WHILE BEGIN...END TRY...CATCH BEGIN TRANSACTION (COMMIT TRANSACTION or ROLLBACK TRANSACTION) |
|
What are the 2 ways to add Comments to a query? |
-- ignore this line /* This is a block of commented code */ |
|
What command does one use to separate batches from each other in a query? |
GO |
|
What is 'Set Theory' in SQL Server? |
A mathematical basis for the relational database model. |
|
What is a 'Set' in SQL Server? |
A collection of definite, distinct objects considered as a whole. |
|
What are the characteristics of a 'Set Element' in SQL Server? |
Elements of a set are: Called Members (such as set of all Customers) Described by Attributes (FirstName, LastName) Must be distinct, or unique (AccountNumber) |
|
What is the purpose of Predicates in T-SQL queries? |
Make comparisons and express the results as TRUE or FALSE, or UNKNOWN (NULL). |
|
What are some uses for Predicates in T-SQL queries? |
Filtering data in queries (WHERE & HAVING clauses) Providing conditional logic to CASE expressions Joining tables (in the ON filter) Defining subqueries (in EXISTS test, for example) Enforcing data integrity (CHECK constraints) Control of Flow (IF statement) |
|
Name the Elements and Expressions of a SELECT statement, in the order they need to be written. Define them, if possible. |
SELECT - select list - columns to return FROM - table source - defines table(s) to query WHERE - search condition - filters rows using a predicate GROUP BY - group by list - arranges rows by groups HAVING - search condition - filters groups using a predicate ORDER BY - order by list - sort the output |
|
Name the order in which Elements are processed in a T-SQL query (the logical order of processing). |
FROM (provides source rows) WHERE (filters rows from source table) GROUP BY (organizes the rows) HAVING (filters out entire groups based on its predicate) SELECT (determines columns to appear in query) |
|
What are the two items you should include in the FROM clause when specifying the table where you will retrieve your data? |
Schema.Object |
|
What character should you use to end all query statements with? |
semicolon (;) |
|
Calculated expressions in a SELECT clause must be __________. |
Scalar (meaning, they must return only a single value) |
|
What is the most basic way to eliminate duplicates in a T-SQL query? |
Using the DISTINCT clause (thus eliminating the hidden default SELECT ALL statement) |
|
What is the one exception clause where you can use an Alias created in the SELECT clause of a query, and why? |
ORDER BY - because of the logical order of processing a SQL query, ORDER BY is processed after SELECT, thus you can refer to your Alias name at that point. |
|
What SQL query clauses allow CASE statements? |
SELECT column list WHERE or HAVING clauses ORDER BY clause |