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 Customer (CustID integer NOT NULL, CustPmtID integer NOT NULL, CustName VARCHAR(25), CustAddress VARCHAR(64), CustPhone VarChar(13), CONSTRAINT Customer_PK PRIMARY KEY (CustID, CustPmtID)); CREATE TABLE Driver (DrvID integer NOT NULL, DrvPmtID integer NOT NULL, DrvStatus boolean, DrvName VARCHAR(25), DrvPhone VARCHAR(13), LicenseNo VARCHAR(16), Plate VARCHAR(16), CONSTRAINT Driver_PK PRIMARY KEY (DrvID, DrvPmtID)); CREATE TABLE Restaurant (RestID integer NOT NULL, RestPmtID integer NOT NULL, RestName VARCHAR(25), RestAddress VARCHAR(64), RestPhone VARCHAR(13), Cuisine VARCHAR(25), CONSTRAINT Restaurant_PK PRIMARY KEY (RestID, RestPmtID)); CREATE TABLE Orders (OrderID integer NOT NULL, CustPmtID integer NOT NULL, RestPmtID integer NOT NULL, DrvPmtID integer NOT NULL, OrderStatus VARCHAR(32), OrderDate VARCHAR(32), CONSTRAINT Order_PK PRIMARY KEY(OrderID), CONSTRAINT Order_Cust_FK FOREIGN KEY(CustPmtID) REFERENCES Customer(CustPmtID), CONSTRAINT Order_Rest_FK FOREIGN KEY(RestPmtID) REFERENCES Restaurant(RestPmtID), CONSTRAINT Order_Drv_FK FOREIGN KEY(DrvPmtID) REFERENCES Driver(DrvPmtID)); CREATE TABLE GrubHub (CustPmtID integer NOT NULL, RestPmtID integer NOT NULL, DrvPmtID integer NOT NULL, CONSTRAINT GrubHub_PK PRIMARY KEY(CustPmtID, RestPmtID, DrvPmtID), CONSTRAINT GrubHub_Cust_FK FOREIGN KEY(CustPmtID) REFERENCES Orders(CustPmtID), CONSTRAINT GrubHub_Rest_FK FOREIGN KEY(RestPmtID) REFERENCES Orders(RestPmtID), CONSTRAINT GrubHub_Drv_FK FOREIGN KEY(DrvPmtID) REFERENCES Orders(DrvPmtID)); /** Insert Statements **/ INSERT INTO Customer(CustID, CustPmtID, CustName, CustAddress, CustPhone) VALUES (1, 23456, "April Ludgate", "123 S 55 Ave, Omaha, NE 68132", "402-553-4397"), (2, 98754, "Leslie Knope", "4387 Waffles Drive, Pawnee, IN 46011", "234-432-5437"), (4, 234789, "Ron Swanson", "987 Bacon Avenue, Pawnee, IN 46011", "456-987-3265"), (5, 12390, "Andy Dwyer", "2468 The Pit, Pawnee, IN 46011", ""); INSERT INTO Driver(DrvID, DrvPmtID, DrvStatus, DrvName, DrvPhone, LicenseNo, Plate) VALUES (1, 444862, 1, "Henry Roth", "286-937-2250", "C04790049", "IUC989"), (2, 959227, 1, "Charity Osborne", "815-605-0336", "D89973937", "REW222"), (3, 718371, 1, "Fritz Macias", "943-893-6193", "U06119817", "XUA177"), (4, 334452, 1, "Brenden Hill", "513-285-9064", "X22173227", "IOL455"), (5, 603268, 0, "Leah Peters", "909-477-8843", "V44276914", "AJA879"); INSERT INTO Restaurant(RestID, RestPmtID, RestName, RestAddress, RestPhone, Cuisine) VALUES (1, 4826, "Paunch Burger", "6872 Lard Lane, Pawnee, IN 46011", "678-893-1568", "Fast food"), (2, 78623, "JJ's Diner", "23428 Main St. Pawnee, IN 46011", "456-987-3185", "Breakfast"), (3, 48623, "Mulligan's", "6876 Classy Rd., Indianapolis, IN 46077", "786-235-4862", "Steakhouse");
SQL
Server:
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
MariaDB 11.5
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