Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize Online / PHPize Online  /  SQLtest Online

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.

Copy Format Clear
CREATE TABLE Studenti( id integer NOT NULL AUTO_INCREMENT, nome varchar(255), cognome varchar(255), classe integer, sezione varchar(2), PRIMARY KEY(id) ); CREATE TABLE Materia( id integer NOT NULL AUTO_INCREMENT, nome_materia varchar(255), nome_docente varchar(255), cognome_docente varchar(255), PRIMARY KEY (id) ); CREATE TABLE Registro( id integer NOT NULL AUTO_INCREMENT, voto integer, id_studente integer, id_materia integer, PRIMARY KEY(id), FOREIGN KEY (id_studente) REFERENCES Studenti(id) ON DELETE CASCADE, FOREIGN KEY (id_materia) REFERENCES Materia(id) ON DELETE CASCADE ); INSERT INTO Studenti(nome, cognome, classe, sezione) VALUES ('Gian Tommaso', 'Sanna', 4, 'BS'); INSERT INTO Studenti(nome, cognome, classe, sezione) VALUES ('Simone', 'Foschini', 4, 'BS'); INSERT INTO Studenti(nome, cognome, classe, sezione) VALUES ('Caterina', 'Rocca', 4, 'BS'); INSERT INTO Studenti(nome, cognome, classe, sezione) VALUES ('Carlo', 'Monti', 4, 'BS'); INSERT INTO Studenti(nome, cognome, classe, sezione) VALUES ('Veronica', 'Cimbri', 4, 'BS'); INSERT INTO Studenti(nome, cognome, classe, sezione) VALUES ('Giovanni', 'Sabbioni', 4, 'BS'); INSERT INTO Studenti(nome, cognome, classe, sezione) VALUES ('Alessandro', 'Cesaretti', 4, 'BS'); INSERT INTO Studenti(nome, cognome, classe, sezione) VALUES ('Veronica', 'Legnani', 4, 'BS'); INSERT INTO Materia(nome_materia, nome_docente, cognome_docente) VALUES ('Scienze', 'Alfreda', 'Zanforlin'); INSERT INTO Materia(nome_materia, nome_docente, cognome_docente) VALUES ('Filosofia, Storia e Religione', 'Giacomo', 'Bettini'); INSERT INTO Materia(nome_materia, nome_docente, cognome_docente) VALUES ('Informatica', 'Alessandro', 'Serra'); INSERT INTO Registro(voto, id_studente, id_materia) VALUES (10, 1, 3); INSERT INTO Registro(voto, id_studente, id_materia) VALUES (2, 1, 2); INSERT INTO Registro(voto, id_studente, id_materia) VALUES (3, 4, 1); INSERT INTO Registro(voto, id_studente, id_materia) VALUES (2, 4, 3); INSERT INTO Registro(voto, id_studente, id_materia) VALUES (8, 3, 3); INSERT INTO Registro(voto, id_studente, id_materia) VALUES (9, 3, 3); SELECT nome, cognome, AVG(voto) as Media, COUNT(voto) as NumeroVoti FROM Studenti, Materia, Registro WHERE id_materia = Materia.id AND id_studente = Studenti.id GROUP BY nome, cognome; DELETE FROM Studenti WHERE id=4; SELECT nome, cognome, AVG(voto) as Media, COUNT(voto) as NumeroVoti FROM Studenti, Materia, Registro WHERE id_materia = Materia.id AND id_studente = Studenti.id GROUP BY id_studente

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear