SQL无法创建缺少右括号的表

时间:2019-04-01 18:37:42

标签: sql oracle

我创建了表employeeSalaire。但是创建表Zone时出现错误:

  

00907-0000缺少右括号

代码:

Create table Employee 
(
    CodeEmploye int,
    NAS Number (9),
    Nom Varchar(20) not null,
    Prenom Varchar(20) not null,
    NomJeuneFille varchar(20) not null,
    DateNaissance Date,   
    Adresse varchar(100) not null,
    Sexe Char(1),
    Telephone Varchar(14),
    Fonction Varchar(20) not null,
    Service varchar(13) not null,
    Taux Number(6,2) default (0),
    Grade Varchar(2),

    Constraint PK_Employe Primary key (CodeEmployee),
    Constraint NAS_Employe Unique (NAS),
    Constraint Verfi_Sexe Check Sexe IN ('F', 'M'),
    Constraint verif_Service Check Service IN ('adminstratif', 'surveillance', 'medical'),   
    Constraint verfi_Grade Check grade in ('G1', 'G2','G3', 'G4', 'G5')
);

Create Table Salaire
(
    CodeEmployee int, 
    Mois int,     
    Salaire Number(11,2) default (0),

    Constraint PK__Salaire Primary key (CodeEmployee, Mois),
    Constraint verif_Mois Check Mois between 1 and 12,
    Constraint FK_Salaire_Employe Foreign Key (CodeEmploye) references Employee(CodeEmployee) 
);

Create Table Zone
(
    CodeZone int,
    NomZone Varchar(20), not null 
    ChefZone Varchar(20),     

    Constraint PK_Zone Primary Key (CodeZone),
    Constraint FK_Zone_Employee Foreign Key (ChefZone) references Employee(Taux, Grade) On delete set null on update cascade

1 个答案:

答案 0 :(得分:0)

您需要在检查后添加括号

Create table Employe (
CodeEmploye int,
NAS Number (9),
Nom Varchar(20) not null,
Prenom Varchar(20) not null,
NomJeuneFille varchar(20) not null,
DateNaissance Date,   
Adresse varchar(100) not null,
Sexe Char(1),
Telephone Varchar(14),
Fonction Varchar(20) not null,
Service varchar(30) not null,
Taux Number(6,2) default 0,
Grade Varchar(2),
Constraint PK_Employe Primary key (CodeEmploye),
CONSTRAINT NAS_Employe Unique  (NAS),
Constraint Verfi_Sexe Check (Sexe IN ('F', 'M')),
Constraint verif_Service Check ( Service IN ('adminstratif', 'surveillance', 'medical')),   
Constraint verfi_Grade Check (grade in ('G1', 'G2','G3', 'G4', 'G5'))
);

Create Table Salaire(
CodeEmploye int, 
Mois int,     
Salaire Number(11,2) default (0),
Constraint PK__Salaire Primary key (CodeEmploye, Mois),
Constraint verif_Mois Check (Mois between 1 and 12),
Constraint FK_Salaire_Employe Foreign Key (CodeEmploye) references Employe(CodeEmploye));

对于第三张表,您需要更正您的前瞻性键定义