SQL part 2 Flashcards

(30 cards)

1
Q

2 primary command types for data manipulation language (DML)

A

data retrieval (“standard” queries) and action queries

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

example of data retrieval query in DML

A

select

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

example of DML action queries

A

insert, update, delete

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

general format for select statement

A

SELECT [DISTINCT | ALL] {* | column1 [AS new_name] }
FROM table_name [alias]
[WHERE conditions]
[GROUP BY column_list] [HAVING condition]
[ORDER BY column_list]

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

for the select statement format, can you do both for the [DISTINCT | ALL] statement

A

no

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

which of the [] {} are required, and which are optional

A

{} is required, [] optional

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

“*” is called a

A

wildcard

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

where clause is a ______ and includes the expressions:

A

conditional filter,
- arithmetic operators
- logical operators
- clauses

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

logical operators

A

and, or, not

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

clauses

A

between, like, in

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

you select WHAT from WHAT

A

column names from table name

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

“*” can replace

A

list of column names (lists entire table/full details)

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

to use the where clause to make a comparison between a field/attribute and a value, you must

A

use the correct syntax to indicate the (matching) data types
- creditlimit < 25
- hiredate = “2017-01-01”

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

using the where clause, you combine instances of _________ into _______

A

arithmetic comparisons, logical statements

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

what where clause checks to see if something does not equal a value

A

…WHERE NOT (X = “Thomas”)

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

using BETWEEN in a where clause is used with _____ to _______

A

logical operator AND, specify a range of values

…WHERE X BETWEEN Y AND Z

17
Q

using where clause, IN can be used to ______
(plus example)

A

combine logical statements separated by ORs

instead of:
…WHERE (X = ‘first’) OR (X = ‘last’)

do:
…WHERE X IN (‘first’, ‘last’)

18
Q

t/f: where clause can identify NULL values

A

true
(where x is/is not null)

19
Q

using where clause, LIKE gives the ability to

A

do simple pattern matching

20
Q

LIKE pattern always expressed as

21
Q

with LIKE, MS Access uses

A

different characters than standard SQL

22
Q

using LIKE to match zero or more characters in MySQL and Access

A

MySQL: %
Access: *

23
Q

using LIKE to match exactly one character in MySQL and Access

A

MySQL: __
Access: #

24
Q

using % for like

A

…WHERE Emp_LastName LIKE “Z%”

25
using ___ for like
...WHERE Emp_Phone LIKE "___9"
26
where clause: RLIKE
- based on regular expressions - uses either RLIKE or REGEXP
27
t/f: LIKE operator more powerful than RLIKE
false. RLIKE more powerful
28
t/f: RLIKE is available in Access
false.
29
fundamental difference between like and rlike
- LIKE matches entire pattern against an attribute value and returns true if they are exactly the same - RLIKE looks for the pattern within the attribute value and returns true if that pattern exists anywhere within it
30
some RLIKE patterns
. - matches any single character t* - matches zero of more instances of letter t t+ - matches one or more instances of the letter t t? - matches zero or one instance of letter t ^A - matches given pattern at beginning of string e$ - matches preceding pattern at beginning of string [A-T] - matches a range of characters [a-dx] - matches any character that is a, b, c, d, or x