Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SQL HW 1 Appline
--Sql Server 2014 Express Edition --Batches are separated by 'go' CREATE TABLE dept ( dept_id INTEGER NOT NULL PRIMARY KEY, dname VARCHAR(20) ); CREATE TABLE emp ( emp_id INTEGER NOT NULL, dept_id INTEGER, FOREIGN KEY (dept_id) REFERENCES dept(dept_id), ename VARCHAR(15), salary NUMERIC(6, 2) ); INSERT INTO dept VALUES (1, 'Marketing'), (2, 'RD'); INSERT INTO emp VALUES (1, 1, 'James', 1000), (2, 2, 'Smith', 2000); CREATE TABLE dept_arch( dept_id INTEGER, dname VARCHAR(20) ); INSERT INTO dept_arch SELECT dept_id, dname FROM dept; UPDATE emp SET salary = salary+salary*0.15 WHERE ename = 'Smith'; UPDATE dept SET dname = 'RandD' WHERE dname = 'RD' DELETE FROM emp WHERE dept_id = 1; TRUNCATE TABLE emp; DROP TABLE emp; /* INSERT INTO emp VALUES (3, 4, 'Black', 3000, 'Active'); - невыполнимая операция, т.к. у нас в таблице emp всего 4 столбца; */ /* INSERT INTO dept VALUES (2, 'Sales'); - невыполнимая операция, т.к. повторяется ключ, который уже занят (2); */ SELECT * FROM emp; SELECT * FROM dept; SELECT * FROM dept_arch;
run
|
edit
|
history
|
help
0
count events by 2 shift cycles using CTE
HOTEL
Find gaps in timesheet data between certain hours
Sample
emp 4
Rank group by
WORK
parameters_in_procedure-join&correlated sub-query content
Life cycle
student