0% found this document useful (0 votes)
12 views

Code Ex2

The document contains SQL code to create tables in a database. It defines tables for clients, orders, order lines, articles, and deliveries. It establishes primary keys and foreign key relationships between the tables. The code also includes example SQL queries against the tables to return data based on various conditions. However, all the sample queries return empty sets, indicating the tables do not contain any data.

Uploaded by

tcoffopharell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Code Ex2

The document contains SQL code to create tables in a database. It defines tables for clients, orders, order lines, articles, and deliveries. It establishes primary keys and foreign key relationships between the tables. The code also includes example SQL queries against the tables to return data based on various conditions. However, all the sample queries return empty sets, indicating the tables do not contain any data.

Uploaded by

tcoffopharell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

CREATION DES TABLES DANS DATABASE

-create table client(noClient int not null, nomClient varchar(20) not null,
noTelephone varchar(15) not null, primary key (noClient));

-create table commande(noCommande int not null, dateCommande date not null,
noClient int not null, primary key (noCommande), Foreign key (noClient) References
client(noClient));

- create table article(noArticle int not null,description varchar(20), prixunitaire


decimal(10,2) not null, quantiteEnStock int default 0 not null CHECK
(quantiteEnStock >=0), primary key(noArticle));
Query OK, 0 rows affected (0.015 sec)

-create table detaillivraison (nolivraison int not null, noCommande int not null,
noArticle int not null, quantitelivree int not null CHECK (quantitelivree > 0),
primary key (nolivraison, noCommande, noArticle), foreign key (nolivraison)
references livraison (nolivraison), foreign key (noCommande, noArticle) references
ligneCommande(noCommande, noArticle));

CODE SQL AU EXCERCICES


a- select noTelephone from client where noTelephone= '(999)-999-9999';
Empty set (0.001 sec)

b- select noCommande, dateCommande, noClient from commande where noCommande >5 and
noClient= 10;
Empty set (0.002 sec)

c- select noArticle, description from article where prixunitaire between '$10' and
'$20';
Empty set (0.000 sec)

d- select noCommande, noTelephone, client.noClient from client, commande where


client.noClient = commande.noClient and dateCommande= '2000-06-04';
Empty set (0.001 sec)

e- select noArticle, commande.noClient, commande.dateCommande from lignecommande,


commande where lignecommande.noCommande= commande.noCommande and noClient=10;
Empty set (0.000 sec)

f- select nolivraison, commande.noClient from detaillivraison, commande where


detaillivraison.noCommande=commande.noCommande and noClient= 10;
Empty set (0.000 sec)

g- select noCommande, count(dateCommande) as totaldateCom from commande where


noCommande=2 and 'commande.dateCommande'= 'commande.totaldateCom';

h- select detaillivraison.nolivraison, livraison.datelivraison,


commande.dateCommande from commande, detaillivraison, livraison where
'commande.noCommande' = 'detaillivraison.noCommande' and 'commande.dateCommande' =
'livraison.datelivraison';

i- select nolivraison, noCommande from detaillivraison;


Empty set (0.001 sec)

j- select client.noClient, nomClient,dateCommande from client inner join commande


on 'client.noClient'='commande.noClient' where commande.dateCommande!= '2000-01-
01';
Empty set (0.000 sec)
k- select * from ligneCommande where noArticle!= 10;
Empty set (0.001 sec)

l-select * from article where description like 'c%';


Empty set (0.001 sec)

m- select * from client where noTelephone!= null;


Empty set (0.001 sec)

n- select * from article having avg(prixunitaire)< prixunitaire;


Empty set (0.002 sec)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy