Data Definition Language


Data definition needs some commands • CREATE : databases and tables creation • DROP: databases and tables suppression • ALTER : tables modifications
Création d’une base de données Syntaxe : CREATE DATABASE name ;
Création d’une table Syntaxe : CREATE TABLE nomdelatable ( Champ1 :typeduchamp1, Champ2 :typeduchamp2, Champn :typeduchampn) Exemple : Définition de données en SQL CREATE TABLE Etudiant ( NumEtu : integer, Nom : string, Ville : string) Cette instruction permet de créer une relation "Etudiant" comportant les propriétés "NumEtu", "Nom" et "Ville".
Suppression d’un champ dans une table : Alter table nomtable DROP nomchamp

Ajout d’un champ dans une table Alter table nomtable ADD nomchamp PROPRIETES DU CHAMP exemple Alter table personnel ADD type VARCHAR (20) NOT NULL Suppression de la clef primaire ALTER TABLE nomtable DROP PRIMARY KEY cette instruction ne supprime pas les champs concernes par la clef primaire Ajout de la clef primaire ALTER TABLE nomtable ADD PRIMARY KEY (nomchamp) Ajout d’un champ dans une table Alter table nomtable ADD nomchamp TYPE ATTRIBUT
Update update etudiant set nom='"+anom+"',prenom='"+aprenom+"',datenaiss='"+adat+"',adresse='"+aadresse+"',loisir='"+aloisir+"'where numero='"+anumero+"'

Eninam BAGNABANA     |         |     bagnadavid@outlook.fr     |