-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
118 lines (111 loc) · 7.7 KB
/
schema.sql
File metadata and controls
118 lines (111 loc) · 7.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
-- Employees Table
CREATE TABLE employees (
id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name VARCHAR2(255) NOT NULL,
email VARCHAR2(255) NOT NULL,
department VARCHAR2(255) NOT NULL
);
-- Insert 50 records in 'employees' table
INSERT INTO employees (name, email, department) VALUES ('John Doe', '[email protected]', 'Sales');
INSERT INTO employees (name, email, department) VALUES ('Jane Smith', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('Bob Johnson', '[email protected]', 'Finance');
INSERT INTO employees (name, email, department) VALUES ('Mary Brown', '[email protected]', 'Human Resources');
INSERT INTO employees (name, email, department) VALUES ('David Lee', '[email protected]', 'Engineering');
INSERT INTO employees (name, email, department) VALUES ('Sarah Green', '[email protected]', 'Sales');
INSERT INTO employees (name, email, department) VALUES ('Mike Davis', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('Karen Wilson', '[email protected]', 'Finance');
INSERT INTO employees (name, email, department) VALUES ('Tom Johnson', '[email protected]', 'Human Resources');
INSERT INTO employees (name, email, department) VALUES ('Lisa Chen', '[email protected]', 'Engineering');
INSERT INTO employees (name, email, department) VALUES ('David Davis', '[email protected]', 'Sales');
INSERT INTO employees (name, email, department) VALUES ('Michelle Rodriguez', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('Christopher Smith', '[email protected]', 'Finance');
INSERT INTO employees (name, email, department) VALUES ('Samantha Brown', '[email protected]', 'Human Resources');
INSERT INTO employees (name, email, department) VALUES ('Charles Kim', '[email protected]', 'Engineering');
INSERT INTO employees (name, email, department) VALUES ('Alexandra Taylor', '[email protected]', 'Sales');
INSERT INTO employees (name, email, department) VALUES ('Richard Wilson', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('Jennifer Lee', '[email protected]', 'Finance');
INSERT INTO employees (name, email, department) VALUES ('Matthew Jones', '[email protected]', 'Human Resources');
INSERT INTO employees (name, email, department) VALUES ('Ava Chen', '[email protected]', 'Engineering');
INSERT INTO employees (name, email, department) VALUES ('William Davis', '[email protected]', 'Sales');
INSERT INTO employees (name, email, department) VALUES ('Natalie Nguyen', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('Joseph Garcia', '[email protected]', 'Finance');
INSERT INTO employees (name, email, department) VALUES ('Rachel Martin', '[email protected]', 'Human Resources');
INSERT INTO employees (name, email, department) VALUES ('Christian Kim', '[email protected]', 'Engineering');
INSERT INTO employees (name, email, department) VALUES ('Hannah Rodriguez', '[email protected]', 'Sales');
INSERT INTO employees (name, email, department) VALUES ('Anthony Johnson', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('Sophia Wilson', '[email protected]', 'Finance');
INSERT INTO employees (name, email, department) VALUES ('Ethan Chen', '[email protected]', 'Human Resources');
INSERT INTO employees (name, email, department) VALUES ('Madison Smith', '[email protected]', 'Engineering');
INSERT INTO employees (name, email, department) VALUES ('Oliver Davis', '[email protected]', 'Sales');
INSERT INTO employees (name, email, department) VALUES ('Grace Nguyen', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('Daniel Garcia', '[email protected]', 'Finance');
INSERT INTO employees (name, email, department) VALUES ('Isabella Martin', '[email protected]', 'Human Resources');
INSERT INTO employees (name, email, department) VALUES ('Mia Kim', '[email protected]', 'Engineering');
INSERT INTO employees (name, email, department) VALUES ('Lucas Rodriguez', '[email protected]', 'Sales');
INSERT INTO employees (name, email, department) VALUES ('Victoria Johnson', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('David Wilson', '[email protected]','Engineering');
INSERT INTO employees (name, email, department) VALUES ('Steven Nguyen', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('Amy Kim', '[email protected]', 'Engineering');
INSERT INTO employees (name, email, department) VALUES ('Anna Martinez', '[email protected]', 'Sales');
INSERT INTO employees (name, email, department) VALUES ('Kevin Kim', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('Catherine Davis', '[email protected]', 'Finance');
INSERT INTO employees (name, email, department) VALUES ('Robert Nguyen', '[email protected]', 'Human Resources');
INSERT INTO employees (name, email, department) VALUES ('Karen Clark', '[email protected]', 'Engineering');
INSERT INTO employees (name, email, department) VALUES ('Mike Wilson', '[email protected]', 'Sales');
INSERT INTO employees (name, email, department) VALUES ('Rachel Lee', '[email protected]', 'Marketing');
INSERT INTO employees (name, email, department) VALUES ('Thomas Johnson', '[email protected]', 'Finance');
INSERT INTO employees (name, email, department) VALUES ('Emily White', '[email protected]', 'Human Resources');
INSERT INTO employees (name, email, department) VALUES ('Brian Brown', '[email protected]', 'Engineering');
commit;
-- Procedure to Generate Sample Data
CREATE OR REPLACE PROCEDURE add_employees (
n IN NUMBER
)
AS
departments employees.department%TYPE := 'Sales,Marketing,Finance,Human Resources,Engineering';
BEGIN
FOR i IN 1..n LOOP
INSERT INTO employees (name, email, department)
VALUES ('Employee ' || i, 'employee' || i || '@example.com', REGEXP_SUBSTR(departments,'[^,]+',1,ROUND(DBMS_RANDOM.VALUE(1,5))));
END LOOP;
COMMIT;
END;
/
-- Generate Sample Employee Data
BEGIN
add_employees(50);
END;
/
-- Employees Salary Table
CREATE TABLE employees_salary (
id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
employee_id NUMBER NOT NULL,
salary NUMERIC(10, 2) NOT NULL,
start_date DATE NOT NULL,
end_date DATE NOT NULL,
bonus FLOAT NOT NULL
);
-- Procedure to Generate Sample Data
CREATE OR REPLACE PROCEDURE generate_employees_salary(n IN NUMBER) AS
BEGIN
FOR i IN 1..n LOOP
INSERT INTO employees_salary (employee_id, salary, start_date, end_date, bonus)
VALUES (FLOOR(DBMS_RANDOM.VALUE(1, 10)), -- generate random employee_id between 1 and 10
ROUND(DBMS_RANDOM.VALUE(50000, 100000), 2), -- generate random salary between 50000 and 100000 with 2 decimal places
TRUNC(SYSDATE - DBMS_RANDOM.VALUE(1, 365)), -- generate random start_date between 1 and 365 days ago
TRUNC(SYSDATE + DBMS_RANDOM.VALUE(1, 365)), -- generate random end_date between today and 365 days from now
ROUND(DBMS_RANDOM.VALUE(5000, 15000), 2)); -- generate random bonus between 5000 and 15000 with 2 decimal places
END LOOP;
COMMIT;
END;
/
-- Generate Sample Employee Salary Data
BEGIN
generate_employees_salary(50); -- generate 50 random records
END;
/
-- Cleanup
-- drop table employees;
-- drop table employees_salary;
-- drop procedure generate_employees_salary;
-- drop procedure add_employees;