我正在用oracle编写数据库,但我对以下错误代码有些困惑:
Error starting at line : 95 in command -
INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (00, 00)
Error at Command Line : 95 Column : 33
Error report -
SQL Error: ORA-00904: "PROJECT_ID": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
我是oracle和sql的新手,不确定哪个标识符无效。
我查看了Bug和项目之间的日期,它们都相关,所以我不确定可能是什么问题。
这可能是个小问题,但使我感到困惑。
我的代码显示在下面,任何帮助将不胜感激:
--CREATE SCRIPTS
/*put your create scripts here – your script should not commented out*/
CREATE TABLE Project
(
Proj_ID integer,
Proj_Name varchar(10),
Proj_Start_Date date,
primary key (Proj_ID)
);
CREATE TABLE Bug
(
Bug_ID integer,
Bug_Type varchar(100),
Bug_Desc varchar(100),
Bug_Time date,
primary key(Bug_ID)
);
CREATE TABLE Engineer
(
Engineer_ID integer,
Engineer_Name varchar(10),
Engineer_Type varchar(20),
primary key (Engineer_ID)
);
CREATE TABLE Bug_Project
(
Bug_ID integer,
Proj_ID integer,
primary key(Bug_ID, Proj_ID),
foreign key(Bug_ID) references Bug (Bug_ID),
foreign key(Proj_ID) references Project (Proj_ID)
);
CREATE TABLE Fix_Allocation
(
Engineer_ID integer,
Bug_ID integer,
primary key(Engineer_ID, Bug_ID),
foreign key(Engineer_ID) references Engineer (Engineer_ID),
foreign key(Bug_ID) references Bug (Bug_ID)
);
CREATE TABLE Test_Allocation
(
Engineer_ID integer,
Bug_ID integer,
primary key(Engineer_ID, Bug_ID),
foreign key(Engineer_ID) references Engineer (Engineer_ID),
foreign key(Bug_ID) references Bug (Bug_ID)
);
CREATE TABLE Note
(
Engineer_ID integer,
Bug_ID integer,
Note_author varchar(10),
Note_contents varchar(20),
primary key(Engineer_ID, Bug_ID),
foreign key(Engineer_ID) references Engineer (Engineer_ID),
foreign key(Bug_ID) references Bug (Bug_ID)
);
COMMIT;
--INSERT SCRIPTS
/*put your insert scripts here – your script should not commented out */
INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (00, 'Project 1', DATE '1980-02-14');
INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (01, 'Project 2', DATE '1985-12-11');
INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (02, 'Project 3', DATE '1992-06-03');
INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (03, 'Project 4', DATE '2000-07-22');
INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (04, 'Project 5', DATE '2012-03-19');
INSERT INTO Project(Proj_ID, Proj_Name, Proj_Start_Date) VALUES (05, 'Project 6', DATE '2015-10-21');
INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (00, 'Crash', 'Software stopped functioning properly and exited', timestamp '1980-03-20 09:26:50');
INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (01, 'Run Time Error', 'Wrong output due to a logical error', timestamp '1982-06-12 11:36:32');
INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (02, 'Compilation Error', 'Problems with the compiler, failed complication of source code', timestamp '1987-07-12 14:11:15');
INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (03, 'Crash', 'Software stopped functioning properly and exited', timestamp '1993-01-31 03:21:17');
INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (04, 'Logical Error', 'Unexpected behavior due to problem in source code', timestamp '1997-04-01 10:46:18');
INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (05, 'Run Time Error', 'Wrong output due to a logical error', timestamp '2001-12-24 12:12:37');
INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (06, 'GUI Error', 'Glitchy interface ', timestamp '2013-09-02 17:11:55');
INSERT INTO Bug(Bug_ID, Bug_Type, Bug_Desc, Bug_Time) VALUES (07, 'Run Time Error', 'Wrong output due to a logical error', timestamp '2016-02-03 11:11:21');
INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (00, 'Ava', 'Tester');
INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (01, 'Alexander', 'Fixer');
INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (02, 'Aiden', 'Fixer');
INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (03, 'Anthony', 'Tester');
INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (04, 'Adam', 'Fixer');
INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (05, 'Alex', 'Tester');
INSERT INTO Engineer(Engineer_ID, Engineer_Name, Engineer_Type) VALUES (06, 'John', 'Fixer');
INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (00, 00);
INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (01, 00);
INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (02, 01);
INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (03, 02);
INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (04, 02);
INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (05, 03);
INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (06, 04);
INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (07, 05);
INSERT INTO Fix_Allocation(Engineer_ID, Bug_ID) VALUES (01, 01);
INSERT INTO Fix_Allocation(Engineer_ID, Bug_ID) VALUES (02, 02);
INSERT INTO Fix_Allocation(Engineer_ID, Bug_ID) VALUES (04, 04);
INSERT INTO Fix_Allocation(Engineer_ID, Bug_ID) VALUES (06, 05);
INSERT INTO Fix_Allocation(Engineer_ID, Bug_ID) VALUES (06, 07);
INSERT INTO Test_Allocation VALUES ();
INSERT INTO Test_Allocation VALUES ();
INSERT INTO Test_Allocation VALUES ();
INSERT INTO Note VALUES ();
INSERT INTO Note VALUES ();
INSERT INTO Note VALUES ();
COMMIT;
--SELECT SCRIPT
/*put your select scripts here (with indication of which query is answered) – your script should not commented out
-- Query 1: List of all the bugs, and their details.
SELECT * FROM Bug;
-- Query 2: List of all bugs, and their notes.
-- Query 3: List of all bugs, with their notes, and the engineers who have written them; sorted by name of engineer.
-- Query 4: List the bugs and how much cumulative time (in hours) they have taken; ordered by time taken.
-- Query 5: The bug that has taken most time to fix, and the projects it is connected to.
COMMIT;
--DROP SCRIPT
/*put your drop scripts here (in the correct order)– your script should not commented out
DROP TABLE Note;
DROP TABLE Test_Allocation;
DROP TABLE Fix_Allocation;
DROP TABLE Engineer;
DROP TABLE Bug_Project;
DROP TABLE Bug;
DROP TABLE Project;
COMMIT;
答案 0 :(得分:1)
非常清楚,您没有使用正确的列ID。
创建import { Injectable } from '@angular/core';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Observable, of, throwError } from 'rxjs';
import { catchError, retry } from 'rxjs/operators';
@Injectable()
export class ApiService {
api: string = 'https://newsapi.org/v2/top-headlines?country=gb&category=entertainment&apiKey=8ee8c21b20d24b37856fc3ab1e22a1e5';
constructor(
private http: HttpClient,
) { }
getAll(): Observable<any> {
return this.http.get(this.api)
.pipe(
catchError(this.handleError)
);
}
private handleError(error: HttpErrorResponse) {
if (error.error instanceof ErrorEvent) {
console.log(error.error.message)
} else {
console.log(error.status)
}
return throwError(
console.log('Something is wrong!'));
};
}
表时:
Bug_Project
当您尝试插入CREATE TABLE Bug_Project
(
Bug_ID integer,
Proj_ID integer, --> You named project ID like this
primary key(Bug_ID, Proj_ID),
foreign key(Bug_ID) references Bug (Bug_ID),
foreign key(Proj_ID) references Project (Proj_ID)
);
时,请使用Bug_Project
而不是Project_ID
:
Proj_ID
您需要做的是更改列名,例如:
INSERT INTO Bug_Project(Bug_ID, Project_ID) VALUES (00, 00); --> you are using Project_ID