Syntax.Joins, Checks Flashcards

1
Q

Syntax

Adding Pk constraint to an existing table using ALTER

A

ALTER TABLE employee
ADD CONSTRAINT empPk PRIMARY KEY
(empId);

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

Syntax

Composite Primary Key

A

ALTER TABLE employee
ADD CONSTRAINT empSkillPk
PRIMARY KEY(empId, skillId);

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

Syntax

Adding Fk Constraint to existing table using ALTER

A

ALTER TABLE employee
ADD CONSTRAINT empFk FOREIGN KEY
(deptId) REFERENCES department (deptId);

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

Syntax

Insert

A

INSERT INTO employee(empId, salaryCode, lName)

Value (5, 1, ‘arianne’);

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

Syntax

Update

A

Update employee
Set lName = ‘Rivera’
Where empId = 5;

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

Syntax

DELETE

A

DELETE FROM employee
WHERE empId = 1;

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

Syntax

SELECT

A

SELECT lName
FROM employee
WHERE empId = 2;

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

Syntax

Inner Join

A

SELECT empName, deptName
FROM employee e INNER JOIN department d
ON e.deptId = d.deptId;

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

Syntax

Left Outer Join

A

SELECT empName, deptName
FROM employee e LEFT OUTER JOIN department d
ON e.deptId = d.deptId;

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

Syntax:

Right Outer Join

A

SELECT empName, deptName
FROM employee e
RIGHT OUTER JOIN department d
ON e.deptId = d.deptId;

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

Identify:

A query pulls information from one or more relations and temporarily creates a new relation

A

Result Set

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

Identify:

Dependent on the outer query. References column or relies on a value from the outer query. Is executed repeatedly, once for each row in the outer query.

A

Correlated

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

Identify:

Independent of the outer query. Does not references any value or column from the outer query. Executed once and the result used by the outer query.

A

Non-correlated

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

Identify:

Another way of combining data from multiple tables

A

Joins

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

Syntax:

Full Outer Join

A

SELECT empName, deptName
FROM employee e
FULL OUTER JOIN department d
ON e.deptId = d.deptId;

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

Syntax:

Union

A

SELECT empName, deptName
FROM employee e
LEFT OUTER JOIN department d
ON e.deptId = d.deptId
UNION
SELECT empName, deptName
FROM employee e
RIGHT OUTER JOIN department d
ON e.deptId = d.deptId;

17
Q

Syntax:

Union All

A

SELECT empName, deptName
FROM employee e
LEFT OUTER JOIN department d
ON e.deptId = d.deptId
UNION ALL
SELECT empName, deptName
FROM employee e
RIGHT OUTER JOIN department d
ON e.deptId = d.deptId

18
Q

Syntax:

Alter and Drop

A

ALTER TABLE employee DROP
CONSTRAINT empFk;

19
Q

Syntax:

Deleting a Database

A

DROP TABLE employee;

20
Q

Syntax:

Check Constraint

A

ALTER TABLE employee
ADD CONSTRAINT lenght
CHECK (LENGH(deptId) >=3);

21
Q

Identify:

Retrieves record that have matching values in both tables based on a specified condition, only the rows with matches in both tables are included in the result set

A

Inner Join

22
Q

Identify:

Returns all records from the left table and any matching records from the right table. If there’s no match, NULL values are returned for the right table’s column

A

Left Outer Join

23
Q

Identify:

Returns all records from the right table along with any matching records from the left table. If there’s no match, NULL values are returned for the left table’s column.

A

Right Outer Join

24
Q

Combines the results of two or more SELECT queries into a single result set, removing duplicate rows

A

Union

25
Q

Combines the results of two or more SELECT queries into a single result set, including all duplicate rows.

A

Union All