2017-03-16 66 views
-2
Create table A_15006977.vehicle. (
     Vin varchar(20) primary key, 
     Vehicle_type char(20) not null, 
     Mileage number(20) not null, 
     Manufacturer char(20) not null 
); 

Insert all 
Into A_15006977.vehicle(vin,vehicle_type,mileage,manufacturer) 
values ('tf1bb2ve533093891','panel van',18 325,'man') 
A_15006977.vehicle(vin,vehicle_type,mileage,manufacturer) 
values  
('tf1bb2ve533093822','standard van',79 885,'ford') 


Select * from dual; 
+1

甲骨文認爲需要逗號是因爲里程值的空間 - 刪除空間並且此錯誤消失。由於create table語句中的車輛點號,您還應該有無效的表名錯誤。 –

回答

1
Create table A_15006977.vehicle (
    Vin   varchar(20) CONSTRAINT vehicle__vin__pk PRIMARY KEY, 
    Vehicle_type char(20) CONSTRAINT vehicle__vehicle_type__nn not null, 
    Mileage  number(20) CONSTRAINT vehicle__mileage__nn not null, 
    Manufacturer char(20) CONSTRAINT vehicle__manufacturer__nn not null 
); 

Insert all 
    Into A_15006977.vehicle(vin,vehicle_type,mileage,manufacturer) 
    VALUES ('tf1bb2ve533093891', 'panel van', 18325, 'man') 
    INTO A_15006977.vehicle (vin,vehicle_type,mileage,manufacturer) 
    values ('tf1bb2ve533093822', 'standard van', 79885, 'ford') 
    SELECT 1 FROM DUAL; 

或者:

Insert Into A_15006977.vehicle(vin,vehicle_type,mileage,manufacturer) 
    SELECT 'tf1bb2ve533093891','panel van', 18325, 'man' FROM DUAL UNION ALL 
    SELECT 'tf1bb2ve533093822','standard van', 79885, 'ford' FROM DUAL; 

注:

  • 您有一個額外的.在DDL語句中的表名后里程中的空格(18 32579 885)需要刪除,並且您需要INTO第二次插入前的關鍵字。
  • 命名你的約束也是有用的(然後你可以很容易地確定在後面的語句中違反了哪個約束)。