DROP TABLE etudiant;
CREATE TABLE etudiant 
(
	nom varchar(10) not null,
	prenom varchar(10) not null,
	Id number(5) default 0,
	age number(5) not null,
	constraint pk_Id primary key (Id)
);

DROP VIEW V_Etudiant;
CREATE VIEW V_Etudiant AS SELECT Nom, Prenom, Age * Age AS AgeCarre FROM etudiant;

DROP SEQUENCE incrementEtudiant;
CREATE SEQUENCE incrementEtudiant START WITH 0 INCREMENT BY 1 MINVALUE 0;

CREATE OR REPLACE TRIGGER trigIncrementEtudiant BEFORE INSERT ON etudiant FOR EACH ROW
BEGIN
   SELECT incrementEtudiant.NEXTVAL INTO :NEW.Id FROM DUAL;
END;
/

INSERT INTO etudiant VALUES ('Gibbon', 'Jean', 0, 3);
INSERT INTO etudiant VALUES ('Gerard', 'ijij', 13, 12);
INSERT INTO etudiant VALUES ('Cruise', 'Tom', 3, 43);
INSERT INTO etudiant VALUES ('Wilson', 'Robert', 2, 55);
INSERT INTO etudiant VALUES ('Vincent', 'Gardeux', 12, 27);
