Text Practice Mode
SQL General Step by Step
created Monday May 12, 15:58 by IZAKcode
0
227 words
2 completed
0
Rating visible after 3 or more votes
saving score / loading statistics ...
00:00
create database ma_base
use ma_base
create table utilisateurs id int primary key auto_increment nom varchar 50 not null email varchar 100 unique date_inscription date
create table commandes id int primary key auto_increment utilisateur_id int montant decimal 10 2 date_commande date
alter table commandes add foreign key utilisateur_id references utilisateurs id
alter table utilisateurs add colonne telephone varchar 15
alter table utilisateurs modify colonne nom varchar 100
alter table commandes rename to achats
alter table utilisateurs rename column telephone to numero_telephone
insert into utilisateurs nom email date_inscription values Jean Dupont jean exemple com 2023 01 01
insert into utilisateurs nom email date_inscription values Alice Martin alice exemple com 2023 02 01
insert into achats utilisateur_id montant date_commande values 1 99 90 2023 03 01
insert into achats utilisateur_id montant date_commande values 2 149 50 2023 03 05
update utilisateurs set nom Jacques Dupont where id 1
delete from utilisateurs where id 3
truncate table achats
drop table utilisateurs
drop database ma_base
select * from utilisateurs
select nom email from utilisateurs where date_inscription between 2023 01 01 and 2023 12 31
select nom from utilisateurs where nom like J pourcent
select count id from utilisateurs
select u nom a montant from utilisateurs u inner join achats a on u id equals a utilisateur_id
select utilisateur_id sum montant from achats group by utilisateur_id having sum montant greater than 100
use ma_base
create table utilisateurs id int primary key auto_increment nom varchar 50 not null email varchar 100 unique date_inscription date
create table commandes id int primary key auto_increment utilisateur_id int montant decimal 10 2 date_commande date
alter table commandes add foreign key utilisateur_id references utilisateurs id
alter table utilisateurs add colonne telephone varchar 15
alter table utilisateurs modify colonne nom varchar 100
alter table commandes rename to achats
alter table utilisateurs rename column telephone to numero_telephone
insert into utilisateurs nom email date_inscription values Jean Dupont jean exemple com 2023 01 01
insert into utilisateurs nom email date_inscription values Alice Martin alice exemple com 2023 02 01
insert into achats utilisateur_id montant date_commande values 1 99 90 2023 03 01
insert into achats utilisateur_id montant date_commande values 2 149 50 2023 03 05
update utilisateurs set nom Jacques Dupont where id 1
delete from utilisateurs where id 3
truncate table achats
drop table utilisateurs
drop database ma_base
select * from utilisateurs
select nom email from utilisateurs where date_inscription between 2023 01 01 and 2023 12 31
select nom from utilisateurs where nom like J pourcent
select count id from utilisateurs
select u nom a montant from utilisateurs u inner join achats a on u id equals a utilisateur_id
select utilisateur_id sum montant from achats group by utilisateur_id having sum montant greater than 100
