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 DATABASE grubhub; USE grubhub; -- Table for Customer CREATE TABLE Customer ( CustomerID INT PRIMARY KEY, Name VARCHAR(100), Address VARCHAR(255), PhoneNumber VARCHAR(15), PaymentID INT, FOREIGN KEY (PaymentID) REFERENCES Payment(PaymentID) ); -- Table for Restaurant CREATE TABLE Restaurant ( RestaurantID INT PRIMARY KEY, Name VARCHAR(100), Address VARCHAR(255), PhoneNumber VARCHAR(15), Cuisine VARCHAR(50), PaymentID INT, FOREIGN KEY (PaymentID) REFERENCES Payment(PaymentID) ); -- Table for Driver CREATE TABLE Driver ( DriverID INT PRIMARY KEY, Name VARCHAR(100), LicensePlate VARCHAR(20), PhoneNumber VARCHAR(15), Status VARCHAR(20), DriverLicenseNumber VARCHAR(20) ); -- Table for Order CREATE TABLE `Order` ( OrderID INT PRIMARY KEY, Timestamp DATETIME, Status VARCHAR(50), PaymentID INT, CustomerID INT, RestaurantID INT, DriverID INT, FOREIGN KEY (PaymentID) REFERENCES Payment(PaymentID), FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID), FOREIGN KEY (RestaurantID) REFERENCES Restaurant(RestaurantID), FOREIGN KEY (DriverID) REFERENCES Driver(DriverID) ); -- Table for Payment CREATE TABLE Payment ( PaymentID INT PRIMARY KEY, Amount DECIMAL(10, 2), PaymentMethod VARCHAR(50), TransactionDetails VARCHAR(255) ); -- Inserting into Payment table INSERT INTO Payment (PaymentID, Amount, PaymentMethod, TransactionDetails) VALUES (23456, 29.99, 'Credit Card', 'Transaction_23456'), (23457, 19.99, 'PayPal', 'Transaction_23457'), (23979, 49.99, 'Debit Card', 'Transaction_23979'), (23910, 24.99, 'Cash', 'Transaction_23910'), (23911, 39.99, 'Credit Card', 'Transaction_23911'); -- Inserting into Customer table INSERT INTO Customer (CustomerID, Name, Address, PhoneNumber, PaymentID) VALUES (1, 'April Ludgate', '1235 5th Ave, Omaha, NE 68132', '402-532-5437', 23456), (2, 'April Ludgate', '1235 5th Ave, Omaha, NE 68132', '402-532-5437', 23456), (3, 'Leslie Knope', '489 Waffles Drive, Pawnee, IN 46011', '202-324-5497', 23979), (4, 'Ron Swanson', '987 Bacon Avenue, Pawnee, IN 46011', '656-987-3265', 23979), (5, 'Andy Dwyer', '246B The Pit, Pawnee, IN 46011', '402-500-3200', 23910); -- Inserting into Restaurant table INSERT INTO Restaurant (RestaurantID, Name, Address, PhoneNumber, Cuisine, PaymentID) VALUES (2345, 'Paunch Burger', '687 Land Lane, Pawnee, IN 46011', '315-634-5869', 'Fast food', 23456), (2346, 'Paunch Burger', '687 Land Lane, Pawnee, IN 46011', '315-634-5869', 'Fast food', 23456), (2435, 'JJ Diner', '2348 Main St, Pawnee, IN 46011', '865-459-5489', 'Breakfast', 23911), (2399, 'Mulligans', '324 Steakhouse Dr, Pawnee, IN 46011', '516-783-5698', 'Steakhouse', 23979); -- Inserting into Driver table INSERT INTO Driver (DriverID, Name, LicensePlate, PhoneNumber, Status, DriverLicenseNumber) VALUES (4826, 'Henry Roth', 'UC0497909', '(206) 897-1250', 'Active', 'REW229'), (4827, 'Charity Osborne', 'UC0497977', '(815) 503-0386', 'Inactive', 'REW227'), (7823, 'Mitch Maxwell', 'UC0518712', '(716) 687-9319', 'Active', 'U054818'), (4829, 'Henry Roth', 'UC0497909', '(206) 897-1250', 'Inactive', 'REW221'); -- Inserting into Order table INSERT INTO `Order` (OrderID, Timestamp, Status, PaymentID, CustomerID, RestaurantID, DriverID) VALUES (344956, '2020-09-30 14:44:00', 'placed', 23456, 1, 2345, 4826), (344958, '2020-09-30 14:46:00', 'fulfilled', 23457, 2, 2346, 4827), (344959, '2020-09-30 14:48:00', 'cancelled', 23979, 3, 2435, 7823), (344960, '2020-09-30 14:50:00', 'out for delivery', 23910, 4, 2399, 4829);
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
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