Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Santara Awa - Copie

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

-- CREATION DE LA BASE DE DONNEES

CREATE USER BANCAIRES IDENTIFIED BY 1234;


-- ATTRIBUTION DES PRIVILEGES
GRANT RESOURCE, CONNECT, DBA TO BANCAIRES;

-- CONNEXION A LA BASE DE DONNEES


CONN
USER-NAME: BANCAIRES
PASSWORD: 1234

-- TABLE CLIENTS
CREATE TABLE CLIENTS (
RIB INT(10),
NOM VARCHAR(20),
PRENOM VARCHAR(20),
NAISSANCE DATE,
VILLE VARCHAR(20),
CONSTRAINT CLIENTS_PK PRIMARY KEY(RIB)
);

-- TABLE COMPTES
CREATE TABLE COMPTES (
NOCOMPTE NUMBER,
RIB VARCHAR(10),
SOLE NUMBER,
DATECOMPTE DATE,
CONSTRAINT COMPTES_PK PRIMARY KEY(NOCOMPTE),
CONSTRAINT COMPTES_CLIENTS_FK FOREIGN KEY (RIB) REFERENCES CLIENTS(RIB)
);

-- TABLE OPERATIONS
CREATE TABLE OPERATINS (
NOP NUMBER,
NOCOMPTE NUMBER,
TOP VARCHAR(255),
MONTANTOP NUMBER,
DATEOP DATE,
CONSTRAINT OPERATIONS_PK PRIMARY KEY(NOP),
CONSTRAINT OPERATIONS_COMPTES_FK FOREIGN KEY(NOCOMPTE) REFERENCES COMPTES(NOCOMPTE)
);

SCENARIO :
1 - ENREGISTRER 7 CLIENTS DANS LA TABLE CLIENTS
INSERT INTO CLIENTS VALUES ('10131810', 'SANTARA', 'AWA', '2020-01-01', 'BAMAKO');
INSERT INTO CLIENTS VALUES ('20131810', 'SIDIBE', 'YACOUBA', '2020-01-01',
'BAMAKO');
INSERT INTO CLIENTS VALUES ('30131810', 'TRAORE', 'CHEICK', '2020-01-01',
'BAMAKO');
INSERT INTO CLIENTS VALUES ('40131810', 'DOUMBIA', 'MOUSSA', '2020-01-01',
'BAMAKO');
INSERT INTO CLIENTS VALUES ('50131810', 'KEITA', 'IBRAHIM', '2020-01-01',
'BAMAKO');
INSERT INTO CLIENTS VALUES ('60131810', 'SACO', 'MARIAM', '2020-01-01', 'BAMAKO');
INSERT INTO CLIENTS VALUES ('70131810', 'MAIGA', 'MAMADOU', '2020-01-01',
'BAMAKO');

2 -
INSERT INTO COMPTES VALUES (1, 'ML', 1500000, '2020-02-16');
INSERT INTO COMPTES VALUES (4, 'ML', 500000, '2020-02-16');
INSERT INTO COMPTES VALUES (2, 'ML', 22500000, '2020-01-16');
INSERT INTO COMPTES VALUES (3, 'ML', 5600000, '2021-02-06');
INSERT INTO COMPTES VALUES (5, 'ML', 75000, '2019-02-16');
INSERT INTO COMPTES VALUES (6, 'ML', 500000, '2022-02-26');

3 -
INSERT INTO OPERATIONS VALUES (1, 4, 'VERSEMENT', 125000, '2021-01-01');
INSERT INTO OPERATIONS VALUES (2, 4, 'RETRAIT', 100000, '2021-01-31');
INSERT INTO OPERATIONS VALUES (3, 1, 'VERSEMENT', 150000, '2021-10-11');
INSERT INTO OPERATIONS VALUES (4, 1, 'VERSEMENT', 100000, '2021-10-12');
INSERT INTO OPERATIONS VALUES (5, 1, 'RETRAIT', 250000, '2021-12-31');

INSERT INTO OPERATIONS VALUES (6, 3, 'VERSEMENT', 150000, '2022-01-01');


INSERT INTO OPERATIONS VALUES (7, 3, 'RETRAIT', 100000, '2022-02-31');
INSERT INTO OPERATIONS VALUES (8, 5, 'VERSEMENT', 75000, '2020-10-11');
INSERT INTO OPERATIONS VALUES (9, 5, 'VERSEMENT', 100000, '2021-10-12');
INSERT INTO OPERATIONS VALUES (10, 5, 'RETRAIT', 100000, '2021-12-31');

REQUETES

1-
SELECT NOM, PRENOM, SUM(OP.MONTANTOP)
FROM CLIENTS JOIN COMPTES CP ON RIB = CP.RIB
JOIN OPERATIONS OP ON CP.NOCOMPTE = OP.NOCOMPTE
WHERE OP.TOP IN ('VERSEMENT);

2-
SELECT NOM, PRENOM, SUM(OP.MONTANTOP)
FROM CLIENTS JOIN OPERATIONS OP ON CP.NOCOMPTE = OP.NOCOMPTE
WHERE OP.TOP IN ('VERSEMENT);

3-
SELECT NOM,PRENOM,SUN(OP.MONTANT)
FROM CLIENT
WHERE OP.TOP IN(RETRAIT);

4-

//EXERCISE 2

1-
CREATE USER YACOUBA IDENTIFIED BY 1234;
GRANT CONNECT, RESOURCE, DBA TO YACOUBA;

2-
CONN
USER-NAME: YACOUBA
PASSWORD: 1234

3-
DESC ETUDIANT;
DESC MATIERE;
DESC EVALUER;

4-
ALTER TABLE ETUDIANT ADD COLUMN FILIERE VARCHAR2(40);
DESC ETUDIANT;

5-
ALTER TABLE ETUDIANT ADD COLUMN EMAIL VARCHAR2(100) UNIQUE;
DESC ETUDIANTS;

6-
ALTER TABLE ETUDIANT MODIFY COLUMN PRENOM VARCHAR2(100);
DESC ETUDIANTS;

7-
ALTER TABLE EVALUER ADD CONSTRAINT NOTE_CHK CHECK (NOTE BETWEEN 0 AND 20);

8-
ALTER TABLE MODULE RENAME COLUMN COEFFMAT TO VARCHAR2(100);
DESC ETUDIANTS;

9-
ALTER TABLE EVALUER DROP COLUMN EVA;

10-
ALTER TABLE ETUDIANT DROP COLUMN FILIERE ;

11-
CREATE TABLE ETUDIANT2 AS SELECT N_ETUDIANT, VILLE FROM ETUDIANT;

12-
ALTER TABLE ETUDIANT2 RENAME TO STUDENT;

13-
DROP TABLE STUDENT

You might also like