代码之家  ›  专栏  ›  技术社区  ›  Sergio Tapia

Oracle SQL脚本出错!

  •  1
  • Sergio Tapia  · 技术社区  · 14 年前

    我在尝试运行此Oracle SQL脚本时收到此错误。有什么帮助吗?

    错误信息

    ((29,21) expected token:; [ ) * + , - / = > DROP WHERE HAVING AND OR NOT ON JOIN FROM GROUP 
    ((34,21) expected token:; [ ) * + , - / = > DROP WHERE HAVING AND OR NOT ON JOIN FROM GROUP 
    ((39,21) expected token:; [ ) * + , - / = > DROP WHERE HAVING AND OR NOT ON JOIN FROM GROUP 
    ((71,26) expected token:; [ ) * + , - / = > DROP WHERE HAVING AND OR NOT ON JOIN FROM GROUP 
    Cargo(90,1) expected token:; ) , DROP NOT ON UNIQUE CONSTRAINT NULL 
    Location(97,1) expected token:; ) , DROP NOT ON UNIQUE CONSTRAINT NULL 
    pretty print error(pp check error:(1,7)CREATE)
    

    SQL脚本

    create table PerTipoEmpleado(
    ID_TipoEmpleado int primary key,
    Descripcion nvarchar2(200)
    );
    
    create table PerArea(
    ID_Area int primary key,
    Nombre nvarchar2(200),
    ID_AreaPadre int references PerArea(ID_Area)
    );
    
    create table PerEstadoCivil(
    ID_EstadoCivil int primary key,
    Descripcion nvarchar2(40)
    );
    
    create table PerTipoContrato(
    ID_TipoContrato int primary key,
    Descripcion nvarchar2(500)
    );
    
    create table PerSexo(
    ID_Sexo int primary key,
    Descripcion nvarchar2(40)
    );
    
    create table PerCargo(
    ID_Cargo int primary key,
    Descripcion nvarchar(200)
    );
    
    create table PerTurno(
    ID_Turno int primary key,
    Descripcion nvarchar(200)
    );
    
    create table PerAFP(
    ID_AFP int primary key,
    Descripcion nvarchar(200),
    Descuento float
    );
    
    
    create table PerTipoSangre(
    ID_TipoSangre int primary key,
    Descripcion nvarchar2(20)
    );
    
    create table PerTipoSeguro(
    ID_TipoSeguro int primary key,
    Descripcion nvarchar2(300)
    );
    
    create table PerEmpleado(
    ID_Empleado int primary key,
    ID_TipoEmpleado int references PerTipoEmpleado(ID_TipoEmpleado),
    ID_Area int references PerArea(ID_Area),
    ID_Cargo int references PerCargo(ID_Cargo),
    ID_EmpleadoPadre int references PerEmplado(ID_Empleado),
    ID_EstadoCivil int references PerEstadoCivil(ID_EstadoCivil),
    ID_Sexo int references PerSexo(ID_Sexo),
    ID_TipoContrato int references PerTipoContrato(ID_TipoContrato),
    ID_FormaPago int references PerFormaPago(ID_FormaPago),
    NumeroDeCuenta int,
    BancoPago nvarchar2(2000),
    ID_TipoSangre int references PerTipoSangre(ID_TipoSangre),
    NotificarAccidenteNombre nvarchar2(500),
    NotificarAccidenteTelefono nvarchar2(100),
    FechaIngreso date,
    FechaBaja date,
    GradoInstruccion nvarchar(200),
    ID_TipoSeguro int references PerTipoSeguro(ID_TipoSeguro),
    Nombre nvarchar2(200),
    Apellido nvarchar2(200),
    Foto nvarchar2(2000),
    ID_Turno int references PerTurno(ID_Turno),
    ID_AFP int references PerAFP(ID_AFP),
    FechaDeNacimiento nvarchar(200),
    LugarDeNacimiento nvarchar(500),
    Carnet int,
    Direccion nvarchar2(200),
    Telefono nvarchar2(30),
    Celular nvarchar2(30)
    );
    
    
    create table PerHistorialLaboral(
    ID_HistorialLaboral int primary key,
    ID_Empleado int references PerEmpleado(ID_Empleado)
    Cargo nvarchar2(400),
    Detalle nvarchar2(400)
    );
    
    create table PerCurriculum(
    ID_Curriculum int primary key,
    ID_Empleado int references PerEmpleado(ID_Empleado)
    Location nvarchar2(2000),
    TituloProfesional nvarchar2(500),
    Habilidades nvarchar2(400),
    );
    
    create table PerTipoObservacion(
    ID_TipoObservacion int primary key,
    Descripcion nvarchar2(200)
    );
    
    create table PerObservaciones(
    ID_Observaciones int primary key,
    ID_Empleado int references PerEmpleado(ID_Empleado),
    Detalle nvarchar2(2000)
    );
    
    2 回复  |  直到 14 年前
        1
  •  2
  •   APC    14 年前

    使用一个合适的文本编辑器,很容易用行号查看脚本。这表明第29、34、39和71行有一些共同点:

    Descripcion nvarchar(200)
    

    尝试 Descripcion nvarchar2(200 )相反(或者你需要的任何精度)。

    更容易诊断其他两个错误:前一行末尾缺少逗号:Try

    create table PerHistorialLaboral(
    ID_HistorialLaboral int primary key,
    ID_Empleado int references PerEmpleado(ID_Empleado),
    Cargo nvarchar2(400),
    Detalle nvarchar2(400)
    );
    
    create table PerCurriculum(
    ID_Curriculum int primary key,
    ID_Empleado int references PerEmpleado(ID_Empleado),
    Location nvarchar2(2000),
    TituloProfesional nvarchar2(500),
    Habilidades nvarchar2(400),
    );
    
        2
  •  1
  •   Jonathan Leffler    14 年前

    可能:

    create table PerCargo(
    ID_Cargo int primary key,
    Descripcion nvarchar(200)
    );
    

    其他表有nvarchar2(xx)。这与在第29、34、29行分组的3个错误是一致的;第79行在一个较大的表的中间,它有一个nvarchar()而不是nvarchar2()。我不知道Oracle不支持nvarchar,但我知道它使用varchar2()而不是plain varchar(),因为从历史上看,它早就弃用了varchar()的一些替代版本。