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 TRANSACTIONS ( [Account] VARCHAR(32) NOT NULL, [TransID] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(), [TransDate] DATETIME NOT NULL, [Location] VARCHAR(128) NOT NULL, [Description] VARCHAR(128) NOT NULL, [Direction] VARCHAR(1) NOT NULL DEFAULT 'O', [Amount] DECIMAL(10,2) NOT NULL, CONSTRAINT [PK_TRANSACTIONS] PRIMARY KEY ([Account] ASC, [TransID] ASC) ); CREATE TABLE HISTORY ( [HistID] INT NOT NULL IDENTITY(1,1), [HistDate] DATETIME NOT NULL DEFAULT GETDATE(), [Account] VARCHAR(32) NOT NULL, [TransID] UNIQUEIDENTIFIER NOT NULL, [TransDate] DATETIME NOT NULL, [Direction] VARCHAR(1) NOT NULL, [Amount] DECIMAL(10,2) NOT NULL, CONSTRAINT [PK_AUDIT] PRIMARY KEY ([HistID] ASC), CONSTRAINT [FK_AUDIT_TRANSACTIONS] FOREIGN KEY ([Account], [TransID]) REFERENCES TRANSACTIONS([Account], [TransID]) ); IF OBJECT_ID('AIT_TRANSACTIONS_HISTORY', 'TR') IS NOT NULL BEGIN DROP TRIGGER AIT_TRANSACTIONS_HISTORY; END; GO CREATE TRIGGER AIT_TRANSACTIONS_HISTORY ON TRANSACTIONS AFTER INSERT AS BEGIN INSERT INTO HISTORY (HistDate, Account, TransID, TransDate, Direction, Amount) SELECT GETDATE(), Account, TransID, TransDate, Direction, Amount FROM inserted; END; GO INSERT INTO TRANSACTIONS (Account, TransDate, Location, Description, Amount) VALUES ( '55396f7b60bb', CAST('2024-10-17 16:22:00' AS DATETIME), 'BW3s', 'Purchase', -57.63 ); INSERT INTO TRANSACTIONS (Account, TransDate, Location, Description, Amount) VALUES ( '55396f7b60bb', CAST('2024-9-20 15:48:00' AS DATETIME), 'Shell', 'Purchase', -40.00 ); INSERT INTO TRANSACTIONS (Account, TransDate, Location, Description, Amount) VALUES ( '55396f7b60bb', CAST('2024-9-19 18:30:00' AS DATETIME), 'Online', 'Payroll', 1845.23 ); INSERT INTO TRANSACTIONS (Account, TransDate, Location, Description, Amount) VALUES ( '55396f7b60bb', CAST('2024-9-18 12:04:00' AS DATETIME), 'Online', 'Overdraw Fee', -35.00 ); INSERT INTO TRANSACTIONS (Account, TransDate, Location, Description, Amount) VALUES ( '55396f7b60bb', CAST('2024-9-17 12:04:00' AS DATETIME), 'Chilis', 'Purchase', -44.28 ); INSERT INTO TRANSACTIONS (Account, TransDate, Location, Description, Amount) VALUES ( '55396f7b60bb', CAST('2024-9-17 8:45:00' AS DATETIME), 'Amazon', 'Purchase', -243.34 ); INSERT INTO TRANSACTIONS (Account, TransDate, Location, Description, Amount) VALUES ( '55396f7b60bb', CAST('2024-9-16 19:23:00' AS DATETIME), 'Foot Locker', 'Purchase', -128.46 ); INSERT INTO TRANSACTIONS (Account, TransDate, Location, Description, Amount) VALUES ( '55396f7b60bb', CAST('2024-9-14 8:30:00' AS DATETIME), 'ATM', 'Withdrawal', -200.00 ); INSERT INTO TRANSACTIONS (Account, TransDate, Location, Description, Amount) VALUES ( '55396f7b60bb', CAST('2024-9-13 16:38:00' AS DATETIME), 'Main Branch', 'Withdrawal', -500.00 ); INSERT INTO TRANSACTIONS (Account, TransDate, Location, Description, Amount) VALUES ( '55396f7b60bb', CAST('2024-9-13 16:22:00' AS DATETIME), 'Main Branch', 'Deposit', 1150.00 ); -- Check Insertion SELECT TransDate, Location, Description, Amount FROM TRANSACTIONS WHERE Account = '55396f7b60bb'; SELECT HistID, HistDate, Account, TransID, TransDate, Amount FROM HISTORY;
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