-1

当我尝试将值插入表中时,我不断收到错误报告 - ORA-01722: invalid number。

我正在使用甲骨文。最初的问题是表存储的主键是表员工的外键,反之亦然,因此我无法插入任何值。所以我将表存储中的外键更改为 NULL 并尝试了但仍然没有用

create table Store(
Store_ID integer primary key,
Warehouse_ID integer not null,
Employee_ID integer,
Owner_name varchar2 (15) not null,
Store_hours varchar (10) not null,
Store_name varchar (20) not null,
Store_Address varchar2 (35) not null,
  CONSTRAINT Warehouse_FK_Store
  FOREIGN KEY (Warehouse_ID)
  REFERENCES Warehouse (Warehouse_ID),
  CONSTRAINT Employee_FK_Store
  FOREIGN KEY (Employee_ID)
  REFERENCES Employee (Employee_ID));

insert into Store
values (101, 1001, NULL , 'Grant Campbell', '7:00am - 10:00pm', 'Papakura', '331-345 Great South Road, Takanini, Auckland, 2110');
4

3 回答 3

1

您的查询是正确的,但是您的 Store_Address varchar 大小太短,并且您的查询大小大于,即您需要将大小更改Store_Address varchar (35)Store_Address varchar (255)

   create table Store(
    Store_ID integer primary key,
    Warehouse_ID integer not null,
    Employee_ID integer,
    Owner_name varchar2 (15) not null,
    Store_hours varchar (10) not null,
    Store_name varchar (20) not null,
    Store_Address varchar2 (255) not null,
      CONSTRAINT Warehouse_FK_Store
      FOREIGN KEY (Warehouse_ID)
      REFERENCES Warehouse (Warehouse_ID),
      CONSTRAINT Employee_FK_Store
      FOREIGN KEY (Employee_ID)
      REFERENCES Employee (Employee_ID));

    insert into Store
    values (101, 1001, NULL , 'Grant Campbell', '7:00am - 10:00pm', 'Papakura', '331-345 Great South Road, Takanini, Auckland, 2110');
于 2019-10-15T10:40:14.190 回答
0

You have problems with the length of the fields. And you should include the columns being inserted.

I don't know what the types are for the referencing keys, but they need to be the same.

This works:

create table Stores (
    Store_ID integer primary key,
    Warehouse_ID integer not null,
    Employee_ID integer,
    Owner_name varchar2 (255) not null,
    Store_hours varchar2(255) not null,
    Store_name varchar2(255) not null,
    Store_Address varchar2(255) not null
    --  CONSTRAINT Warehouse_FK_Store  FOREIGN KEY (Warehouse_ID) REFERENCES Warehouse (Warehouse_ID),
    --  CONSTRAINT Employee_FK_Store FOREIGN KEY (Employee_ID) REFERENCES Employee (Employee_ID)    
);

insert into Stores (Store_ID, Warehouse_ID, Employee_ID, Owner_name, Store_Hours, Store_name, Store_Address)
    values (101, 1001, NULL , 'Grant Campbell', '7:00am - 10:00pm', 'Papakura', '331-345 Great South Road, Takanini, Auckland, 2110');

See here.

Here is a version with the foreign key constraints.

于 2019-10-15T10:34:24.690 回答
0

给定值 '331-345 Great South Road, Takanini, Auckland, 2110331-345 Great South Road, Takanini, Auckland, 2110' 大小为 100。对应创建的列 'Store_Address' 大小为 35。

如果您增加列 'Store_Address ' 的大小,它将起作用。

于 2019-10-15T12:21:44.250 回答