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
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; CREATE TABLE IF NOT EXISTS `file` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `link` VARCHAR(255) NOT NULL, `type` VARCHAR(50) NOT NULL ); CREATE TABLE IF NOT EXISTS `dc_language` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `code` VARCHAR(10) NOT NULL, `locale` VARCHAR(10) NOT NULL, `direction` ENUM ('LTR', 'RTL') DEFAULT 'LTR', UNIQUE KEY `unique_code` (`code`), UNIQUE KEY `unique_locale` (`locale`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; CREATE TABLE IF NOT EXISTS `dc_phrases` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `title` VARCHAR(255) NOT NULL, `content` TEXT NOT NULL, `code` VARCHAR(10) NOT NULL, FOREIGN KEY (`code`) REFERENCES `dc_language` (`code`) ON DELETE CASCADE, UNIQUE KEY `unique_dc_phrase` (`title`, `code`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; INSERT IGNORE INTO dc_language (name, code, locale, direction) VALUES ('English', 'en', 'en_US', 'LTR'), ('Ukrainian', 'uk', 'uk_UA', 'LTR'); INSERT IGNORE INTO dc_phrases (title, content, code) VALUES -- English phrases ('add', 'Add', 'en'), ('remove', 'Remove', 'en'), ('update', 'Update', 'en'), ('cancel', 'Cancel', 'en'), ('save', 'Save', 'en'), -- Ukrainian phrases ('add', 'Додати', 'uk'), ('remove', 'Видалити', 'uk'), ('update', 'Оновити', 'uk'), ('cancel', 'Скасувати', 'uk'), ('save', 'Зберегти', 'uk'); CREATE TABLE IF NOT EXISTS `menu` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL ); CREATE TABLE IF NOT EXISTS `menu_item` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `menu_id` INT NOT NULL, `name` VARCHAR(255) NOT NULL, `parent` INT DEFAULT 0, `position` INT DEFAULT 0, `link` VARCHAR(255) NOT NULL, FOREIGN KEY (`menu_id`) REFERENCES `menu` (`id`) ON DELETE CASCADE ); CREATE TABLE IF NOT EXISTS `dc_modules` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `version` VARCHAR(20) NOT NULL, `is_active` BOOLEAN DEFAULT FALSE, `is_install` BOOLEAN DEFAULT FALSE, `vendor` VARCHAR(255) NOT NULL, `main_controller` VARCHAR(255) NOT NULL ); CREATE TABLE IF NOT EXISTS `dc_settings` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `param` VARCHAR(255) NOT NULL, `value` TEXT ); CREATE TABLE IF NOT EXISTS `dc_user` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `login` VARCHAR(255) NOT NULL UNIQUE, `password` VARCHAR(255) NOT NULL, `hash` VARCHAR(255) DEFAULT NULL ); CREATE TABLE IF NOT EXISTS `dc_roles` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL UNIQUE, `permissions` TEXT NOT NULL ); INSERT INTO `dc_roles` (`name`, `permissions`) VALUES ('Unregistered / unconfirmed', 'view_content'), ('Registered', 'view_content,comment'), ( 'Moderating', 'view_content,comment,edit_content,delete_content' ), ( 'Administrative', 'view_content,comment,edit_content,delete_content,manage_settings' ); ALTER TABLE `dc_user` ADD COLUMN `role_id` INT, ADD CONSTRAINT `fk_user_role` FOREIGN KEY (`role_id`) REFERENCES `dc_roles` (`id`); CREATE TABLE IF NOT EXISTS `dc_permissions` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL UNIQUE ); INSERT INTO `dc_permissions` (`name`) VALUES ('view_content'), ('comment'), ('edit_content'), ('delete_content'), ('manage_settings'); CREATE TABLE IF NOT EXISTS `dc_role_permissions` ( `role_id` INT, `permission_id` INT, PRIMARY KEY (`role_id`, `permission_id`), FOREIGN KEY (`role_id`) REFERENCES `dc_roles` (`id`), FOREIGN KEY (`permission_id`) REFERENCES `dc_permissions` (`id`) ); COMMIT;
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