exam 3 - Basic SQL Queries Flashcards

1
Q

SQL Sub-Structures

A

DML: Data Manipulation Language
DDL: Data Definition Language
DCL: Data Control Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

DML: Data Manipulation Language
◦Select Data
◦Modify Data

A

DML: Data Manipulation Language
◦Select Data
◦Modify Data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

DDL: Data Definition Language
◦Create Artifacts
◦Drop Artifacts
◦Modify Artifacts

A

DDL: Data Definition Language
◦Create Artifacts
◦Drop Artifacts
◦Modify Artifacts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

DCL: Data Control Language

◦Securing Artifacts

A

DCL: Data Control Language

◦Securing Artifacts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define Database Objects

A

Define Database Objects

  • create
  • alter
  • drop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

null [important]

A

unknown

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Data Control Language [3 important words]
Manage security and Permissions
[3]

A

manage security and permission

  • grant - set it
  • revoke - remove
  • deny - trump card [you can deny it to a certain user]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Data manipulation language [4 key words, important for the exam]
select and modify data
[4]

A
Select and modify Data
- select - read the data 
- insert
 - update 
 - delete 
Most SQL that you will write will fall into this category
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Database queries return _____

A

Database queries return information

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A SQL Query is structured in sections

- select :

A

SELECT: Column list to return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A SQL Query is structured in sections

- from:

A

FROM: Table list which will be the source

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A SQL Query is structured in sections

- where:

A

WHERE: Row filter criteria

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A SQL Query is structured in sections

order by:

A

ORDER BY: Sort Rules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A SQL Query is structured in sections

- group by:

A

GROUP BY: Organize columns into groups

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A SQL Query is structured in sections

having:

A

HAVING: Group filter criteria

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Simplest form requires only

[2]

A

Simplest form requires only

  • select
  • from
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Select all columns by using a *

[2]

A

Select all columns by using a *

  • careful not to ask for more than you need
  • take extra time to resolve SELECT list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Providing a list of columns is better

[2]

A

Providing a list of columns is better

  • reduce data
  • explicit Resolution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Returning Calculated Values

- A SELECT list can also contain

A

A SELECT list can also contain calculated data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Returning Calculated Values

- Encourages the return of

A

Encourages the return of relevant data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Returning Calculated Values

- Reassembles

A

Reassembles normalized data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

SELECT AuthorID, FirstName + ‘ ‘ + LastName as NameFROM Authors

A

select the column first +

adding a space + Last Name as Name (make a new column named Name, Name isn’t in the Data”)

FROM Authors
(getting it from the Authors files)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

as statements

A

gives a name for the column

24
Q

The WHERE clause allows

A

The WHERE clause allows row filtering

25
where clause | - Further reduces data
Further reduces
26
where clause | - With indexes, can improve ______
With indexes, can improve performance
27
where clause | - Filters can use data not in the ______ ______
Filters can use data not in the Select List
28
where clause
filters it to only a certain word u use for example if you want the data to only show motorcycles WHERE LastName = ‘motorcycles’
29
Standard comparison operators can be used in the WHERE clause
, <=, >=, =, <>
30
Can compare strings or numbers | ◦Depending on the
Can compare strings or numbers | ◦Depending on the install, comparisons may be case-sensitive
31
If you want revenues less than 50 the string would be
WHERE revenue < 50
32
Logical Operators - Complex filters can be created using logical operators [3]
- and - or - not
33
String Comparisons When comparing strings, use the LIKE operator with Wildcards ◦ ◦ ◦
String Comparisons When comparing strings, use the LIKE operator with Wildcards ◦%, replace 0 to many characters ◦_, replace a single character ◦[], replace a single specific character
34
s%
s% = anything that begins with a letter S (S%)
35
s_
s_ = anything that has one character after S (S_)
36
s[] = A[tup]%
s[] = a [t OR u OR p] % [ only 3 letters]
37
need to use ____ for WildCards
need to use LIKE for WildCards
38
Using Lists - Use the IN operator to filter __ - Similar to using an OR ____
Using Lists - Use the IN operator to filter by values in a list - Similar to using an OR operator
39
SELECT SlotMast_ID, SlotNumber FROM CDS_SlotMastWHERE SlotMast_ID = 1 OR SlotMast_ID = 2 SELECT SlotMast_ID, SlotNumber FROM CDS_SlotMastWHERE SlotMast_ID IN (1,2)
same thing just easier to use IN so you have to type an OR statement
40
Data Ranges - ____ ______ can use the BETWEEN operator - BETWEEN always includes the ______
Data Ranges - Range filters can use the BETWEEN operator - BETWEEN always includes the endpoints
41
BETWEEN 1 AND 15
get 1-15
42
Removing Duplicates - Filtering out _____ requires the DISTINCT keyword in the SELECT list - Reduce __ ___ ..
Removing Duplicates - Filtering out duplicates requires the DISTINCT keyword in the SELECT list - Reduce redundant data which lowers bandwidth
43
Using Functions - SQL has ___ ◦ ◦
Using Functions - SQL has numerous built-in functions ◦CURDATE ◦COUNT, AVG, MIN, MAX
44
Using Functions a in SELECT list | - SELECT Count(*) FROM Authors:
Using Functions a in SELECT list | - SELECT Count(*) FROM Authors: number of rows
45
WHERE LastLoggedInDate > CURDATE()
WHERE LastLoggedInDate > CURDATE(): people who login before our current date
46
Sorting Data - Sort data using the ORDER BY ____ - Multiple sort columns are separated by _____ - You can sort by any ___ ___ ; does not have to be in the SELECT list
Sorting Data - Sort data using the ORDER BY clause - Multiple sort columns are separated by commas - You can sort by any available field; does not have to be in the SELECT list
47
Grouping Data - The GROUP BY clause allows you to - Any data not grouped must be - Use Functions for
Grouping Data - The GROUP BY clause allows you to aggregate data into groups - Any data not grouped must be aggregated - Use Functions for aggregation
48
``` Joining Tables - Relational databases separate data into multiple tables [2] ◦ ◦ ```
``` Joining Tables - Relational databases separate data into multiple tables [2] ◦Reduces data redundancy ◦Eases data maintenance ```
49
Joining Tables - data in different tables can be correlated [2]
Joining Tables - data in different tables can be correlated - use join statements - correlate on common data fields
50
Joining tables | - cautions:
Joining tables | - cautions: can reduce performance
51
The JOIN Operator - Correlates data by - You must identify the
The JOIN Operator - Correlates data by finding matching data in two different tables - You must identify the tables and the correlation fields
52
inner join
add two tables and correlates the data between each other
53
SQL is NOT a programming language
SQL is NOT a programming language
54
Data manipulation language
Data manipulation language
55
•Lacks many programming constructs
•Lacks many programming constructs