Unit 3 Flashcards

(28 cards)

1
Q

SELECT * INTO Table

A

used for copy data to another.

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

DELETE

A

remove row(s).

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

TRUNCATE

A

remove all rows.

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

DROP

A

remove table.

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

UPDATE

A

change the values in row(s) for one table at a time. Used with SET and WHERE.

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

SET

A

specific columns to contain specific values. Nested select statement can be used here to make that value and aggregate. Used with UPDATE.

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

Which of these commands does not change the tables in a DB?
- INSERT
- DELETE
- UPDATE
- SELECT

A

SELECT

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

LIKE

A

Used with the “%” character. Also used as NOT LIKE.

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

SELECT CONCAT(attr1, attr2) FROM Table

A

Used to represent values of two attributes in one column.

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

SELECT studentName AS Name FROM TABLE

A

Alias, used to label columns of results to clarify query results.

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

UPPER(), LOWER()

A

change casing of results.

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

LTRIM(), RTRIM()

A

take trailing spaces or specific characters off of values in column.

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

LEFT(), RIGHT()

A

selecting only a part of the characters in values in column.

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

CAST(attr1 AS INT)

A

Used to cast the datatypes of a column. Usually used with ROUND().

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

WHERE empID IN (‘AJ01’, ‘GB01’)

A

Used to find a list of specific values in a column.

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

Is CAST() the same as ROUND()

A

CAST() changes the datatype and chops off extra numbers instead of rounding, ROUND() rounds the value.

17
Q

ROUND(151.42) AS INT

A

Rounds the values to a less precise datatype.

18
Q

DATEDIFF(metric, attr1, attr2)

A
  • Used to find difference between to dates according to a time metric.
  • Ex: DATEDIFF(years, birthDate, GETDATE()) finds a person’s age in years.
  • date2 - date1
19
Q

DATEADD(metric, metric added, attr1)

A
  • Not used to edit values in DB; used to add values pulled from DB to format query.
  • Ex: DATEADD(years, 1, hireDate) returns the 1 year anniversary for employee’s hire.
  • Ex: DATEADD(months, -6, hireDate) returns the date 6 months before an employee was hired. DATEADD can be used to “DATESUBTRACT.”
20
Q

SELECT TOP 2 WITH TIES empID, firstName, lastName, salary

A

Returns even more than the top 2 values if the second highest ties with lower ranked values.

21
Q

What order is alphabetical ascending?

22
Q

What order is numerical ascending?

A

0 to 100; increasing.

23
Q

OFFSET 3 rows

A

offsets query results. OFFSET 3 Rows: query results are everything omitting the top 3 rows that should have appeared without OFFSET; Used with FETCH NEXT

24
Q

FETCH NEXT 5 rows only;

A

Used with OFFSET; works with OFFSET; Finds n rows after OFFSET. In the above query it works with OFFSET to return rows 4, 5, 6, 7, 8.

25
Boolean Order of Operations
Parenthesis NOT AND OR
26
CREATE Constraints
Not Null Identity(start, increment) Default _________ Unique Check (attribute IN (“1”, “2”, “3”))
27
CREATE Datatypes
Char(n) Varchar(n) Nvarchar(n),Nchar(n) Int(n) SmallInt(n) TinyInt(n) Date Decimal(total(not including decimal point), nums after decimal)
28
CREATE Refernence
Foreign Key (VINNo) References Car(VINNo) Primary Key (BldgNum, UnitNum) references Booking (BldgNum, UnitNum)