Bonjour à tous,
Dans cet article nous allons voir l’équivalent des requêtes vues la semaine passée en algèbre relationnel.
Projection
SELECT col1, col2
FROM nomTable
;
nomTable [col1, col2]
Restriction :
SELECT col1, col2
FROM nomTable
WHERE condition
;
nomTable [col1, col2] { condition }
Union :
SELECT col1, col2
FROM table1
UNION
SELECT col1, col3
FROM table2
;
table1 [col1, col2] U table2 [col1, col3]
Intersection :
SELECT col1, col2
FROM table1
INTERSECT
SELECT col1, col3
FROM table2
;
table1 [col1, col2] ∩ table2 [col1, col3]
Différence :
SELECT col1, col2
FROM table1
MINUS
SELECT col1, col3
;
table1 [col1, col2] \ table2 [col1, col3]
Produit cartésien :
SELECT *
FROM table1, table2
;
table1 x table2
JOINTURES :
Équi-jointure :
SELECT *
FROM r1, r2
WHERE r1.col1 = r2.col1
;
r1 [ col1 = col1 ] r2
Théta-jointure :
SELECT *
FROM r1, r2
WHERE condition
;
r1 [ condition ] r2
Renommage colonne :
SELECT col1 AS uneColonne
FROM r1
;
r1 [col1 AS uneColonne ]
Si vous pensez que cette série d’articles peut intéresser d’autres personnes,vous pouvez partager cet article sur les réseaux sociaux et par mail à vos amis.
Pour toutes questions vous pouvez me contacter par mail ou via l’onglet “Contact” en haut du site.
Merci !