Syntax.Joins, Checks Flashcards
Syntax
Adding Pk constraint to an existing table using ALTER
ALTER TABLE employee
ADD CONSTRAINT empPk PRIMARY KEY
(empId);
Syntax
Composite Primary Key
ALTER TABLE employee
ADD CONSTRAINT empSkillPk
PRIMARY KEY(empId, skillId);
Syntax
Adding Fk Constraint to existing table using ALTER
ALTER TABLE employee
ADD CONSTRAINT empFk FOREIGN KEY
(deptId) REFERENCES department (deptId);
Syntax
Insert
INSERT INTO employee(empId, salaryCode, lName)
Value (5, 1, ‘arianne’);
Syntax
Update
Update employee
Set lName = ‘Rivera’
Where empId = 5;
Syntax
DELETE
DELETE FROM employee
WHERE empId = 1;
Syntax
SELECT
SELECT lName
FROM employee
WHERE empId = 2;
Syntax
Inner Join
SELECT empName, deptName
FROM employee e INNER JOIN department d
ON e.deptId = d.deptId;
Syntax
Left Outer Join
SELECT empName, deptName
FROM employee e LEFT OUTER JOIN department d
ON e.deptId = d.deptId;
Syntax:
Right Outer Join
SELECT empName, deptName
FROM employee e
RIGHT OUTER JOIN department d
ON e.deptId = d.deptId;
Identify:
A query pulls information from one or more relations and temporarily creates a new relation
Result Set
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.
Correlated
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.
Non-correlated
Identify:
Another way of combining data from multiple tables
Joins
Syntax:
Full Outer Join
SELECT empName, deptName
FROM employee e
FULL OUTER JOIN department d
ON e.deptId = d.deptId;