Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle SQL错误无效标识符_Sql_Oracle_Database Design - Fatal编程技术网

Oracle SQL错误无效标识符

Oracle SQL错误无效标识符,sql,oracle,database-design,Sql,Oracle,Database Design,编辑:我解决了空值问题。现在我对无效的标识符感到困惑 我的任务是将ER图转换为SQL中创建的表 我有我的代码张贴在下面,但我得到了不少不同的错误。它们大多是重复出现的错误,但有2-3种不同的错误 有人能帮我解决这个问题吗 COMMIT; CREATE TABLE Team ( Team_ID INTEGER GENERATED ALWAYS AS IDENTITY, Team_Name NVARCHAR2(40) NOT NULL, Team_Manager VARCHAR2(20

编辑:我解决了空值问题。现在我对无效的标识符感到困惑

我的任务是将ER图转换为SQL中创建的表

我有我的代码张贴在下面,但我得到了不少不同的错误。它们大多是重复出现的错误,但有2-3种不同的错误

有人能帮我解决这个问题吗

COMMIT;

CREATE TABLE Team (
  Team_ID INTEGER GENERATED ALWAYS AS IDENTITY,
  Team_Name NVARCHAR2(40) NOT NULL,
  Team_Manager VARCHAR2(20),
  CONSTRAINT kkeyconst PRIMARY KEY(Team_ID)
);

COMMIT;

  insert into Team(TEAM_NAME, TEAM_MANAGER) VALUES ('Red Sox', 'Jon');
  insert into Team(TEAM_NAME, TEAM_MANAGER) VALUES('White Sox', 'Tony');


CREATE TABLE Driver (
  Driver_id INTEGER,
  Team_ID INTEGER NOT NULL,
  Driver_age INTEGER NOT NULL,
  Driver_Name VARCHAR(20) NOT NULL,
  CONSTRAINT DriverAge CHECK (Driver_age BETWEEN '19' AND '65'),
  CONSTRAINT driverpk PRIMARY KEY(Driver_ID),
  CONSTRAINT Team_FK FOREIGN KEY (Team_ID) REFERENCES Team(Team_ID)
);

 COMMIT;

  INSERT INTO Driver(DRIVER_AGE,DRIVER_NAME) VALUES ('21','jon');
  INSERT INTO Driver(DRIVER_AGE,DRIVER_NAME) VALUES ('43','Tony');

  SELECT * FROM DRIVER;

CREATE TABLE Participation (
   Team_ID INTEGER,
  Driver_ID INTEGER NOT NULL,
  Points INTEGER,
  CONSTRAINT Team_FK FOREIGN KEY (Team_ID) REFERENCES Team(Team_ID),
  CONSTRAINT Driver_FK FOREIGN KEY(Driver_ID) REFERENCES Driver(Driver_ID)
);

COMMIT;
  insert into Participation(Participation_Points) VALUES (150);
  INSERT INTO Participation(Participation_Points) VALUES(300);

  SELECT * FROM PARTICIPATION;


CREATE TABLE Finish (
  Driver_ID INTEGER,
  Finish_Position INTEGER NOT NULL,
  Finish_Result VARCHAR2(50)  NOT NULL,
  CONSTRAINT Driver_FK FOREIGN KEY (Driver_ID) REFERENCES Driver(Driver_id)
);

COMMIT;
  INSERT INTO Finish(Driver_ID, Finish_POSITION, Finish_Result) VALUES ('3','1','Winner');
  INSERT INTO Finish(Driver_ID, Finish_POSITION, Finish_Result) VALUES ('4','3','ThirdPlace');

  SELECT * FROM FINISH;

CREATE TABLE RaceComponent (
  RC_ID INTEGER,
  Driver_ID INTEGER,
  RC_Type VARCHAR(25),
  CONSTRAINT Rcpk  PRIMARY KEY(RC_ID),
  CONSTRAINT Driver_FK FOREIGN KEY (Driver_ID) REFERENCES Driver(Driver_ID)
);

COMMIT;
  INSERT INTO RaceComponent(RC_ID,RC_TYPE) VALUES ('47','Hot Wheels');
  INSERT INTO RaceComponent(RC_ID,RC_TYPE) VALUES ('3', 'Tonka');

  SELECT * FROM RACECOMPONENT;


CREATE TABLE Race (
  Race_Id INTEGER NOT NULL,
  RC_ID INTEGER NOT NULL,
  Race_Title VARCHAR(30) NOT NULL,
  Race_Location VARCHAR(50) NOT NULL,
  Race_Date DATE,
  CONSTRAINT RACE_PK PRIMARY KEY(RACE_ID),
  CONSTRAINT RC_FK FOREIGN KEY (RC_ID) REFERENCES RaceComponent(RC_ID)
 );

 COMMIT;

 INSERT INTO Race(RACE_TITLE, RACE_LOCATION, RACE_DATE) VALUES ('Tonys       Race','Moncton', DATE '2016-04-25');
 INSERT INTO Race(Race_Title, Race_Location, Race_Date) VALUES ('Mikes Racing','San-Francisco', DATE '2015-04-25');

 SELECT * FROM RACE;
错误:

Error starting at line : 29 in command -
INSERT INTO Driver(DRIVER_AGE,DRIVER_NAME) VALUES ('21','jon')
Error report -
SQL Error: ORA-01400: cannot insert NULL into   ("STUDENT"."DRIVER"."DRIVER_ID")
01400. 00000 -  "cannot insert NULL into (%s)"
*Cause:    An attempt was made to insert NULL into previously listed objects.
*Action:   These objects cannot accept NULL values.

Error starting at line : 30 in command -
INSERT INTO Driver(DRIVER_AGE,DRIVER_NAME) VALUES ('43','Tony')
Error report -
SQL Error: ORA-01400: cannot insert NULL into   ("STUDENT"."DRIVER"."DRIVER_ID")
01400. 00000 -  "cannot insert NULL into (%s)"
*Cause:    An attempt was made to insert NULL into previously listed objects.
*Action:   These objects cannot accept NULL values.

 DRIVER_ID   TEAMS_ID DRIVER_AGE DRIVER_NAME        
---------- ---------- ---------- --------------------
     1                    21 jon                 
     2                    43 Tony                


Error starting at line : 34 in command -
CREATE TABLE Participation (
  Team_ID INTEGER,
  Driver_ID INTEGER NOT NULL,
  Points INTEGER,
  CONSTRAINT Team_FK FOREIGN KEY (Team_ID) REFERENCES Team(Team_ID),
   CONSTRAINT Driver_FK FOREIGN KEY(Driver_ID) REFERENCES Driver(Driver_ID)
)
Error report -
SQL Error: ORA-00955: name is already used by an existing object
00955. 00000 -  "name is already used by an existing object"
*Cause:    
*Action:

Commit complete.


Error starting at line : 43 in command -
insert into Participation(Participation_Points) VALUES (150)
Error at Command Line : 43 Column : 27
Error report -
SQL Error: ORA-00904: "PARTICIPATION_POINTS": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:

Error starting at line : 44 in command -
INSERT INTO Participation(Participation_Points) VALUES(300)
Error at Command Line : 44 Column : 27
Error report -
SQL Error: ORA-00904: "PARTICIPATION_POINTS": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:

                        TEAMNAME_ID  DRIVER_ID
--------------------------------------- ----------
                       POINTSEARNED
---------------------------------------

                                150


                                150


                                150

Commit complete.


Error starting at line : 57 in command -
INSERT INTO Finish(Driver_ID, Finish_POSITION, Finish_Result) VALUES    ('3','1','Winner')
Error at Command Line : 57 Column : 48
Error report -
SQL Error: ORA-00904: "FINISH_RESULT": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:

Error starting at line : 58 in command -
INSERT INTO Finish(Driver_ID, Finish_POSITION, Finish_Result) VALUES    ('4','3','ThirdPlace')
Error at Command Line : 58 Column : 48
Error report -
SQL Error: ORA-00904: "FINISH_RESULT": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:

no rows selected

Commit complete.


  Error starting at line : 71 in command -
  INSERT INTO RaceComponent(RC_ID,RC_TYPE) VALUES ('47','Hot Wheels')
Error report -
SQL Error: ORA-00001: unique constraint (STUDENT.RCPK) violated
00001. 00000 -  "unique constraint (%s.%s) violated"
*Cause:    An UPDATE or INSERT statement attempted to insert a duplicate   key.
       For Trusted Oracle configured in DBMS MAC mode, you may see
       this message if a duplicate entry exists at a different level.
*Action:   Either remove the unique restriction or do not insert the key.

Error starting at line : 72 in command -
INSERT INTO RaceComponent(RC_ID,RC_TYPE) VALUES ('3', 'Tonka')
Error report -
SQL Error: ORA-00001: unique constraint (STUDENT.RCPK) violated
00001. 00000 -  "unique constraint (%s.%s) violated"
*Cause:    An UPDATE or INSERT statement attempted to insert a duplicate    key.
       For Trusted Oracle configured in DBMS MAC mode, you may see
       this message if a duplicate entry exists at a different level.
*Action:   Either remove the unique restriction or do not insert the key.

     RC_ID DRIVER1_ID RC_TYPE                 
---------- ---------- -------------------------
    47            Hot Wheels               
     3            Tonka                    


Commit complete.

Error starting at line : 89 in command -
INSERT INTO Race(RACE_TITLE, RACE_LOCATION, RACE_DATE) VALUES ('Tonys    Race','Moncton', DATE '2016-04-25')
Error report -
SQL Error: ORA-01400: cannot insert NULL into ("STUDENT"."RACE"."RACE_ID")
01400. 00000 -  "cannot insert NULL into (%s)"
*Cause:    An attempt was made to insert NULL into previously listed objects.
*Action:   These objects cannot accept NULL values.

Error starting at line : 90 in command -
INSERT INTO Race(Race_Title, Race_Location, Race_Date) VALUES ('Mikes    Racing','San-Francisco', DATE '2015-04-25')
Error report -
SQL Error: ORA-01400: cannot insert NULL into ("STUDENT"."RACE"."RACE_ID")
01400. 00000 -  "cannot insert NULL into (%s)"
*Cause:    An attempt was made to insert NULL into previously listed objects.
*Action:   These objects cannot accept NULL values.

   RACE_ID      RC_ID RACE_TITLE
---------- ---------- ------------------------------
RACE_LOCATION                                      RACE_DATE
-------------------------------------------------- ---------
     1            Tonys Race                     
Moncton                                            25-APR-16

    43            MikesRacing                    
San-Francisco                                      25-APR-15

你在一小时前发布了同样的问题,得到了回答:@dnoeth-不是同一个问题,我被告知要做一个新问题。感谢mate的关注。错误消息非常清楚:
无法在“学生”、“驾驶员”、“驾驶员ID”中插入NULL
。您在
DRIVER
表中将列
DRIVER\u ID
声明为
NOT NULL
,然后您不能将NULL插入此列-这很明显。您还不清楚什么?在我的编辑中-我发现了,现在我对
无效标识符
感到困惑。“参与点”是什么?参与表中未定义。