Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- rediction de l'execution en même temps
- -- sur un fichier text
- spool F:\plsql\G2\trace_creaschema_V2.txt
- -- pour voir les commande à l'ecran avant execution
- set echo on;
- -- nettoyage pour retester et recréer le schéma
- drop table ligne_commande;
- drop table commande;
- drop table produit;
- drop table client;
- -- creation du schéma de la BD
- -- en crée les contraintes d'integrité refrentielle
- -- au même temps que les tables
- -- creation de la table client
- create table client(
- NUMCLI NUMBER(7),
- NOM VARCHAR2(50),
- PRENOM VARCHAR2(25),
- TELEPHONE VARCHAR2(25),
- ADRESSE VARCHAR2(200) ,
- VILLE VARCHAR2(30),
- PAYS VARCHAR2(30),
- CONSTRAINT PK_CLIENT PRIMARY KEY (NUMCLI)
- );
- -- verif
- desc client
- -- la table produit
- create table produit(
- NUMPROD NUMBER(7),
- DESIGNATION VARCHAR2(50),
- DESCRIPTION VARCHAR2(200),
- PRIX NUMBER(11,2),
- QTESTOCK NUMBER (9),
- CONSTRAINT PK_PROD PRIMARY KEY (NUMPROD)
- );
- -- verif
- desc produit
- -- la table commande
- create table commande(
- NUMCOM NUMBER(7),
- NUMCLI NUMBER(7),
- DATECOM DATE,
- DATELIVRAI DATE,
- CONSTRAINT PK_COM PRIMARY KEY (NUMCOM),
- CONSTRAINT FK_COM_CLI FOREIGN KEY (NUMCLI) REFERENCES CLIENT(NUMCLI)
- );
- -- verif
- desc commande
- -- la table ligne_commande
- create table ligne_commande(
- NUMCOM NUMBER(7),
- NUMPROD NUMBER(7),
- PRIX NUMBER(11,2),
- QTECOM NUMBER(9),
- CONSTRAINT PK_LINCOM PRIMARY KEY (NUMCOM, NUMPROD),
- CONSTRAINT FK_LINCOM_COM FOREIGN KEY (NUMCOM) REFERENCES COMMANDE(NUMCOM),
- CONSTRAINT FK_LINCOM_PROD FOREIGN KEY (NUMPROD) REFERENCES PRODUIT(NUMPROD)
- );
- -- veirf
- desc ligne_commande
- -- verif sur le dico
- select table_name from user_tables;
- -- les contraites
- select constraint_name from user_constraints;
- -- fin de rediction
- spool off;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement