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 tbl_pokemongames ( poke_game_id CHAR(10) PRIMARY KEY NOT NULL, poke_game_name VARCHAR(150), poke_game_region VARCHAR(50), poke_game_platform VARCHAR(50) ); -- Table CREATE TABLE tbl_nationaldex ( pokemon_generation INT NOT NULL, pokemon_id INT PRIMARY KEY NOT NULL, pokemon_name VARCHAR(150) NOT NULL, pokemon_type VARCHAR(200) NOT NULL, pokemon_base_stats INT NOT NULL ); CREATE TABLE tbl_fireredleafgreen ( poke_game_id CHAR(10) DEFAULT 'frld' NOT NULL, pokemon_id INT AUTO_INCREMENT PRIMARY KEY NOT NULL, pokemon_national_id INT UNIQUE NOT NULL, pokemon_name VARCHAR(150) NOT NULL, pokemon_type VARCHAR(200) NOT NULL, pokemon_base_stats INT NOT NULL, pokemon_location VARCHAR(150) NOT NULL, CONSTRAINT pk_poke_game_id_frld FOREIGN KEY (poke_game_id) REFERENCES tbl_pokemongames(poke_game_id), CONSTRAINT pk_poke_naional_id_frld FOREIGN KEY (pokemon_national_id) REFERENCES tbl_nationaldex(pokemon_id) ); CREATE TABLE tbl_rubysapphireemerald ( pokemon_game_id CHAR(10) DEFAULT 'rse' NOT NULL, pokemon_id INT AUTO_INCREMENT PRIMARY KEY NOT NULL, pokemon_national_id INT UNIQUE NOT NULL, pokemon_name VARCHAR(150) NOT NULL, pokemon_type VARCHAR(200) NOT NULL, pokemon_base_stats INT NOT NULL, pokemon_location VARCHAR(150) NOT NULL, CONSTRAINT pk_poke_game_id_rse FOREIGN KEY (pokemon_game_id) REFERENCES tbl_pokemongames(poke_game_id), CONSTRAINT pk_poke_naional_id_rse FOREIGN KEY (pokemon_national_id) REFERENCES tbl_nationaldex(pokemon_id) ); INSERT INTO tbl_pokemongames (poke_game_id, poke_game_name, poke_game_region, poke_game_platform) VALUES ('rby', 'Red Blue and Yellow', 'Kanto', 'Game Boy'), ('frld', 'FireRed and LeafGreen', 'Kanto', 'Game Boy Advance'), ('rse', 'Ruby Sapphire and Emerald', 'Hoenn', 'Game Boy Advance'), ('hgss', 'HeartGold and SoulSilver', 'Johto', 'Nintendo DS'), ('p', 'Platinum', 'Sinnoh', 'Nintendo DS'), ('oras', 'Omega Ruby and Alpha Sapphire', 'Hoenn', '3DS'), ('sm', 'Sun and Moon', 'Alola', '3DS'); INSERT INTO tbl_nationaldex (pokemon_generation, pokemon_id, pokemon_name, pokemon_type, pokemon_base_stats) VALUES (1, 1, 'Bulbasaur', 'Grass, Poison', 318), (1, 2, 'Ivysaur', 'Grass, Poison', 405), (1, 3, 'Venusaur', 'Grass, Poison', 525), (3, 252, 'Treecko', 'Grass', 318), (3, 253, 'Grovyle', 'Grass', 405), (3, 254, 'Sceptile', 'Grass', 530); INSERT INTO tbl_fireredleafgreen (pokemon_national_id, pokemon_name, pokemon_type, pokemon_base_stats, pokemon_location) VALUES (1, 'Bulbasaur', 'Grass, Poison', 318, 'Pallet Town'), (2, 'Ivysaur', 'Grass, Poison', 405, 'Evolve Bulbasaur'), (3, 'Venusaur', 'Grass, Poison', 525, 'Evolve Bulbasaur/Ivysaur'); INSERT INTO tbl_rubysapphireemerald (pokemon_national_id, pokemon_name, pokemon_type, pokemon_base_stats, pokemon_location) VALUES (252, 'Treecko', 'Grass', 318, 'Route 101'), (253, 'Grovyle', 'Grass', 405, 'Evolve Treecko'), (254, 'Sceptile', 'Grass', 530, 'Evolve Treecko/Grovyle'); DELIMITER // CREATE FUNCTION fn_search_pokemon_game_and_region (_game VARCHAR(150), _region VARCHAR(150)) RETURNS VARCHAR(500) BEGIN DECLARE result VARCHAR(500); SET result = 'No matching records found'; SELECT CONCAT('Game Name: ', poke_game_name, ', Region: ', poke_game_region, ', Platform: ', poke_game_platform) INTO result FROM tbl_pokemongames WHERE LOWER(poke_game_name) like CONCAT('%', LOWER(_game), '%') and LOWER(poke_game_region) like CONCAT('%', LOWER(_region), '%') LIMIT 1; RETURN result; END// DELIMITER ; select fn_search_pokemon_game_and_region ('red', 'kanto')
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