0% found this document useful (0 votes)
8 views1 page

Correction TP N°2

The document outlines SQL commands for creating and modifying database tables related to clients and vehicle rentals. It includes the creation of tables 'Client', 'Vehicule', and 'Location', along with various alterations to these tables such as adding, modifying, and dropping columns. Additionally, it specifies constraints and primary keys for data integrity and relationships between the tables.

Uploaded by

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

Correction TP N°2

The document outlines SQL commands for creating and modifying database tables related to clients and vehicle rentals. It includes the creation of tables 'Client', 'Vehicule', and 'Location', along with various alterations to these tables such as adding, modifying, and dropping columns. Additionally, it specifies constraints and primary keys for data integrity and relationships between the tables.

Uploaded by

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

Chapitre V 4éme SI (BD)

Correction TP n°2
3. CREATE TABLE Client(
NCIN_Cli VARCHAR(8) PRIMARY KEY,
Nom_Cli VARCHAR(20) NOT NULL,
Prenom_Cli VARCHAR(20) NOT NULL,
Adresse_Cli VARCHAR(50),
Ville VARCHAR(20)
);
CREATE TABLE Vehicule(
immat_Vehicule VARCHAR(10) primary key,
marque VARCHAR(20) NOT NULL CHECK( marque in ('Peugeot','Renault','Fiat','Opel',
'Volkswagen','Citroën')),
model VARCHAR(20) NOT NULL,
date_acq INT(4) NOT NULL
);

CREATE TABLE Location(


immat_Vehicule VARCHAR(10) REFERENCES vehicule(immat_Vehicule)ON DELETE
CASCADE,
NCIN_Cli VARCHAR(8) REFERENCES Client(NCIN_Cli)ON DELETE CASCADE,
date_loc DATE CHECK(date_loc<=NOW()),
duree_loc INT(3) CHECK(duree_loc>0),
cout_loc DECIMAL(8,3) CHECK(cout_loc>0),
CONSTRAINT PK_Location PRIMARY KEY(immat_Vehicule,NCIN_Cli)
);
4. ALTER TABLE Client ADD COLUMN Tel_Cli VARCHAR(10);

5. ALTER TABLE Client MODIFY COLUMN Tel_Cli INT(8);

6. ALTER TABLE Client DROP COLUMN Adresse_Cli ;

7. ALTER TABLE Vehicule ADD CONSTRAINT Vc CHECK (Annee_Acq BETWEEN 1990

AND 2008);

8. ALTER TABLE Client MODIFY COLUMN Ville VARCHAR(20) DEFAULT 'tunis';

9. ALTER TABLE Location DROP PRIMARY KEY;

ALTER TABLE Location ADD PRIMARY KEY (immat_Vehicule,NCIN_Cli,date_loc);

10. ALTER TABLE Client DISABLE KEYS;

11.ALTER TABLE Client ENABLE KEYS;

12. DROP TABLE Client;

Chtioui Neirouz

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