Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

TP3 - CRÉATION ET MISE À

JOUR (CORRECTION)
Une première requête pour effacer les éventuelles tables existantes.

DROP TABLE if exists personnel;


DROP TABLE if exists cabinet;

Question 3

CREATE TABLE cabinet


(
id serial primary key,
nom varchar(64),
adresse varchar(256)
);

CREATE TABLE personnel


(
id serial primary key,
nom varchar(64),
prenom varchar(64),
fonction varchar(256),
cabinet integer references cabinet(id)
);

Question 4

INSERT INTO cabinet values (DEFAULT, 'Aod An Aber', ' 31 Rue de la Roche
sur Foron, 29290 SAINT RENAN');

Question 5

Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
INSERT INTO personnel (nom, prenom, cabinet) VALUES ('DUPONT', 'Thomas',
1);
INSERT INTO personnel VALUES (DEFAULT, 'AIMÉE', 'Elisabeth', 'Secrétaire
médicale', 1);

Question 6

DELETE FROM personnel WHERE nom='AIMÉE' AND prenom='Elisabeth';

Question 7

UPDATE personnel SET fonction='Brancardier' WHERE nom='DUPONT' and


prenom='Thomas';

Question 8

ALTER TABLE medecin ADD COLUMN cabinet integer REFERENCES cabinet(id);

Question 9

INSERT INTO cabinet VALUES (1, 'Nouveau cabinet', 'Nouvelle adresse');

UPDATE cabinet SET id=null WHERE id=1;

Question 10

INSERT INTO personnel VALUES (DEFAULT, 'AIMÉE', 'Elisabeth', 'Secrétaire


médicale', 4);

Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
UPDATE personnel SET cabinet=10 WHERE nom='DUPONT' and prenom='Thomas';

Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com

You might also like