SQLize
Online
/
PHPize Online
/
SQLtest Online
A
A
A
Share
Donate
Blog
Popular
Donate
A
A
A
Share
Blog
Popular
SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code.
You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.
SQL code:
Upload
Copy
Format
Clear
CREATE TABLE Employees ( id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, first_name VARCHAR2(100) NOT NULL, last_name VARCHAR2(100) NOT NULL, position VARCHAR2(100) NOT NULL, payment_type VARCHAR2(50) NOT NULL, hire_date DATE NOT NULL ); CREATE TABLE WorkTime ( id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, employee_id NUMBER, work_date DATE NOT NULL, hours_worked NUMBER NOT NULL, tasks_completed NUMBER, FOREIGN KEY (employee_id) REFERENCES Employees(id) ); CREATE TABLE Salaries ( id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, employee_id NUMBER, salary_date DATE NOT NULL, base_salary DECIMAL(10, 2) NOT NULL, bonuses DECIMAL(10, 2), deductions DECIMAL(10, 2), total_salary DECIMAL(10, 2) NOT NULL, FOREIGN KEY (employee_id) REFERENCES Employees(id) ); CREATE TABLE Departments ( id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name VARCHAR2(100) NOT NULL UNIQUE, manager_id NUMBER, FOREIGN KEY (manager_id) REFERENCES Employees(id) ); -- Insert into Employees table INSERT INTO Employees (first_name, last_name, position, payment_type, hire_date) VALUES ('Ivan', 'Ivanov', 'Слесарь', 'Hourly', TO_DATE('2020-01-01', 'YYYY-MM-DD')); INSERT INTO Employees (first_name, last_name, position, payment_type, hire_date) VALUES ('Sergey', 'Petrov', 'Монтажник', 'Monthly', TO_DATE('2021-06-15', 'YYYY-MM-DD')); INSERT INTO Employees (first_name, last_name, position, payment_type, hire_date) VALUES ('Alexei', 'Sidorov', 'Уборщик', 'Hourly', TO_DATE('2019-03-25', 'YYYY-MM-DD')); INSERT INTO Employees (first_name, last_name, position, payment_type, hire_date) VALUES ('Mikhail', 'Kovalenko', 'Директор', 'Monthly', TO_DATE('2018-11-10', 'YYYY-MM-DD')); -- Insert into WorkTime table INSERT INTO WorkTime (employee_id, work_date, hours_worked, tasks_completed) VALUES (1, TO_DATE('2024-12-18', 'YYYY-MM-DD'), 8, 5); INSERT INTO WorkTime (employee_id, work_date, hours_worked, tasks_completed) VALUES (2, TO_DATE('2024-12-18', 'YYYY-MM-DD'), 7, 3); INSERT INTO WorkTime (employee_id, work_date, hours_worked, tasks_completed) VALUES (3, TO_DATE('2024-12-18', 'YYYY-MM-DD'), 6, 4); INSERT INTO WorkTime (employee_id, work_date, hours_worked, tasks_completed) VALUES (4, TO_DATE('2024-12-18', 'YYYY-MM-DD'), 8, 6); -- Insert into Salaries table INSERT INTO Salaries (employee_id, salary_date, base_salary, bonuses, deductions, total_salary) VALUES (1, TO_DATE('2024-12-18', 'YYYY-MM-DD'), 3000.00, 500.00, 100.00, 3400.00); INSERT INTO Salaries (employee_id, salary_date, base_salary, bonuses, deductions, total_salary) VALUES (2, TO_DATE('2024-12-18', 'YYYY-MM-DD'), 4000.00, 700.00, 200.00, 4500.00); INSERT INTO Salaries (employee_id, salary_date, base_salary, bonuses, deductions, total_salary) VALUES (3, TO_DATE('2024-12-18', 'YYYY-MM-DD'), 2000.00, 200.00, 50.00, 2150.00); INSERT INTO Salaries (employee_id, salary_date, base_salary, bonuses, deductions, total_salary) VALUES (4, TO_DATE('2024-12-18', 'YYYY-MM-DD'), 5000.00, 1000.00, 300.00, 5700.00); -- Insert into Departments table INSERT INTO Departments (name, manager_id) VALUES ('Engineering', 4); INSERT INTO Departments (name, manager_id) VALUES ('Cleaning', 3); INSERT INTO Departments (name, manager_id) VALUES ('HR', 2); INSERT INTO Departments (name, manager_id) VALUES ('IT', 1); ALTER TABLE Employees ADD CONSTRAINT fk_department_manager FOREIGN KEY (id) REFERENCES Departments(manager_id); ALTER TABLE Salaries ADD CONSTRAINT chk_salary CHECK (base_salary > 0); CREATE SYNONYM emp FOR Employees; SELECT * FROM emp;
SQL
Server:
MariaDB 11.4
MariaDB 11.5
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
SQLite 3
SQLite 3 Preloaded
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 11
PostgreSQL 12
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
Version
ER Diagram
Preserve result
Stuck with a problem?
Got Error?
Ask ChatGPT!
Result:
Copy
Clear