問題は存在しないORA-00907:欠落している右括弧とORA-00942:表またはビューが、私が午前
- ORA-00907です:欠落している右括弧と
- ORA-00942:表またはビューは存在しません。エラーの
スクリーンショットは、データベース内に作成する必要があり、テーブルで表される
DROP TABLE Organizer CASCADE CONSTRAINT;
DROP TABLE festival CASCADE CONSTRAINT;
DROP TABLE staff CASCADE CONSTRAINT;
DROP TABLE act CASCADE CONSTRAINT;
DROP TABLE equipment CASCADE CONSTRAINT;
DROP TABLE stage CASCADE CONSTRAINT;
DROP TABLE band CASCADE CONSTRAINT;
DROP TABLE agent CASCADE CONSTRAINT;
DROP TABLE venue CASCADE CONSTRAINT;
DROP TABLE band_agent CASCADE CONSTRAINT;
表作成
- モデルの各エンティティです。
- SQL内では、CREATE TABLEコマンドを使用して新しいテーブルが作成されます。
- テーブルが作成されるときにその名前とその属性が定義されます。
- この値はモデルで指定された値から派生しています。
- プライマリキーの識別など、特定の制約も指定されることがあります。
-- Create a Database table to represent the "Organizer" entity.
CREATE TABLE Organizer(
OrganizerId INTEGER NOT NULL,
oranizerName VARCHAR(55) NOT NULL,
organizerAddress VARCHAR(55),
organizerPhone INTEGER,
-- Specify the PRIMARY KEY constraint for table "Organizer".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_Organizer PRIMARY KEY (OrganizerId)
);
-- Create a Database table to represent the "festival" entity.
CREATE TABLE festival(
festvalId INTEGER NOT NULL,
festivalName VARCHAR(55) NOT NULL,
festvalLocation VARCHAR(55) NOT NULL,
festivalPeriod INTEGER,
fk1_OrganizerId NUMBER NOT NULL,
-- Specify the PRIMARY KEY constraint for table "festival".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_festival PRIMARY KEY (festvalId)
);
-- Create a Database table to represent the "staff" entity.
CREATE TABLE staff(
staffId INTEGER NOT NULL,
fk1_venueId INTEGER NOT NULL,
fk2_staffId INTEGER NOT NULL,
-- Specify the PRIMARY KEY constraint for table "staff".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_staff PRIMARY KEY (staffId)
);
-- Create a Database table to represent the "equipment" entity.
CREATE TABLE equipment(
equipmentmodel INTEGER NOT NULL,
equipmentname VARCHAR(55),
equipmenttype VARCHAR(55),
fk1_stageId INTEGER NOT NULL,
-- Specify the PRIMARY KEY constraint for table "equipment".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_equipment PRIMARY KEY (equipmentmodel));
-- Create a Database table to represent the "act" entity.
CREATE TABLE act(
actId INTEGER NOT NULL,
typeOfAct VARCHAR(55) NOT NULL,
actName VARCHAR(55),
fk1_bandId INTEGER NOT NULL,
fk2_festvalId INTEGER NOT NULL,
fk3_stageId INTEGER NOT NULL,
-- Specify the PRIMARY KEY constraint for table "act".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_act PRIMARY KEY (actId)
);
-- Create a Database table to represent the "stage" entity.
CREATE TABLE stage(
stageId INTEGER NOT NULL,
-- Specify the PRIMARY KEY constraint for table "stage".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_stage PRIMARY KEY (stageId)
);
-- Create a Database table to represent the "band" entity.
CREATE TABLE band(
bandId INTEGER NOT NULL,
bandName VARCHAR(55),
bandAddress VARCHAR(55),
bandPhone INTEGER,
-- Specify the PRIMARY KEY constraint for table "band".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_band PRIMARY KEY (bandId)
);
-- Create a Database table to represent the "agent" entity.
CREATE TABLE agent(
agentId INTEGER NOT NULL,
agentName VARCHAR(55),
agentAddress VARCHAR(55),
agentPhone INTEGER,
-- Specify the PRIMARY KEY constraint for table "agent".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_agent PRIMARY KEY (agentId)
);
-- Create a Database table to represent the "venue" entity.
CREATE TABLE venue(
venueId INTEGER NOT NULL,
venueName VARCHAR(55) NOT NULL,
venueLocation VARCHAR(55),
venueType VARCHAR(55),
fk1_festvalId INTEGER NOT NULL,
-- Specify the PRIMARY KEY constraint for table "venue".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_venue PRIMARY KEY (venueId)
);
-- Create a Database table to represent the "band_agent" entity.
CREATE TABLE band_agent(
fk1_bandId INTEGER NOT NULL,
fk2_agentId INTEGER NOT NULL
);
-- Create a Database table to represent the "first aider" entity.
-- This table is representing a sub-type entity, so the primary key will be the same as that
-- defined for table "staff" which represents the super-type entity.
CREATE TABLE first_aider(
staffId INTEGER NOT NULL,
name VARCHAR(25),
-- Specify the PRIMARY KEY constraint for table "first_aider".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_first_aider PRIMARY KEY (staffId),
-- Specify a FOREIGN KEY constraint to indicate that this table's primary key (staffId)
-- references the super-type table's primary key. In this case the key of table "staff"
-- The ON DELETE CASCADE and ON UPDATE CASCADE ensure that if the super-type key data is
-- deleted or updated then the changes will be cascaded down to this sub-type.
-- i.e. if the value of the super-type key is changed the value of this table's key is also changed.
FOREIGN KEY(staffId) REFERENCES staff(staffId) ON DELETE CASCADE ON UPDATE CASCADE
);
-- Create a Database table to represent the "security" entity.
-- This table is representing a sub-type entity, so the primary key will be the same as that
-- defined for table "staff" which represents the super-type entity.
CREATE TABLE security(
staffId INTEGER NOT NULL,
name VARCHAR(55),
-- Specify the PRIMARY KEY constraint for table "security".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_security PRIMARY KEY (staffId),
-- Specify a FOREIGN KEY constraint to indicate that this table's primary key (staffId)
-- references the super-type table's primary key. In this case the key of table "staff"
-- The ON DELETE CASCADE and ON UPDATE CASCADE ensure that if the super-type key data is
-- deleted or updated then the changes will be cascaded down to this sub-type.
-- i.e. if the value of the super-type key is changed the value of this table's key is also changed.
FOREIGN KEY(staffId) REFERENCES staff(staffId) ON DELETE CASCADE ON UPDATE CASCADE
);
-- Create a Database table to represent the "supervisor" entity.
-- This table is representing a sub-type entity, so the primary key will be the same as that
-- defined for table "staff" which represents the super-type entity.
CREATE TABLE supervisor(
staffId INTEGER NOT NULL,
name VARCHAR(8),
-- Specify the PRIMARY KEY constraint for table "supervisor".
-- This indicates which attribute(s) uniquely identify each row of data.
CONSTRAINT pk_supervisor PRIMARY KEY (staffId),
-- Specify a FOREIGN KEY constraint to indicate that this table's primary key (staffId)
-- references the super-type table's primary key. In this case the key of table "staff"
-- The ON DELETE CASCADE and ON UPDATE CASCADE ensure that if the super-type key data is
-- deleted or updated then the changes will be cascaded down to this sub-type.
-- i.e. if the value of the super-type key is changed the value of this table's key is also changed.
FOREIGN KEY(staffId) REFERENCES staff(staffId) ON DELETE CASCADE ON UPDATE CASCADE
);
--------------------------------------------------------------
-- Alter Tables to add fk constraints --
-- Now all the tables have been created the ALTER TABLE command is used to define some additional
-- constraints. These typically constrain values of foreign keys to be associated in some way
-- with the primary keys of related tables. Foreign key constraints can actually be specified
-- when each table is created, but doing so can lead to dependency problems within the script
-- i.e. tables may be referenced before they have been created. This method is therefore safer.
-- Alter table to add new constraints required to implement the "organizer_to_festival" relationship
-- This constraint ensures that the foreign key of table "festival"
-- correctly references the primary key of table "Organizer"
ALTER TABLE festival ADD CONSTRAINT fk1_festival_to_Organizer FOREIGN KEY(fk1_OrganizerId) REFERENCES Organizer(OrganizerId);
-- Alter table to add new constraints required to implement the "stage_to_equipment" relationship
-- This constraint ensures that the foreign key of table "equipment"
-- correctly references the primary key of table "stage"
ALTER TABLE equipment ADD CONSTRAINT fk1_equipment_to_stage FOREIGN KEY(fk1_stageId) REFERENCES stage(stageId);
-- Alter table to add new constraints required to implement the "band_to_acts" relationship
-- This constraint ensures that the foreign key of table "act"
-- correctly references the primary key of table "band"
ALTER TABLE act ADD CONSTRAINT fk1_act_to_band FOREIGN KEY(fk1_bandId) REFERENCES band(bandId);
-- Alter table to add new constraints required to implement the "festival_to_act" relationship
-- This constraint ensures that the foreign key of table "act"
-- correctly references the primary key of table "festival"
ALTER TABLE act ADD CONSTRAINT fk2_act_to_festival FOREIGN KEY(fk2_festvalId) REFERENCES festival(festvalId);
-- Alter table to add new constraints required to implement the "festival_to_venue" relationship
-- This constraint ensures that the foreign key of table "venue"
-- correctly references the primary key of table "festival"
ALTER TABLE venue ADD CONSTRAINT fk1_venue_to_festival FOREIGN KEY(fk1_festvalId) REFERENCES festival(festvalId);
-- Alter table to add new constraints required to implement the "band_to_band_agent" relationship
-- This constraint ensures that the foreign key of table "band_agent"
-- correctly references the primary key of table "band"
ALTER TABLE band_agent ADD CONSTRAINT fk1_band_agent_to_band FOREIGN KEY(fk1_bandId) REFERENCES band(bandId);
-- Alter table to add new constraints required to implement the "agent_to_band_agent" relationship
-- This constraint ensures that the foreign key of table "band_agent"
-- correctly references the primary key of table "agent"
ALTER TABLE band_agent ADD CONSTRAINT fk2_band_agent_to_agent FOREIGN KEY(fk2_agentId) REFERENCES agent(agentId);
-- Alter table to add new constraints required to implement the "supervises" relationship
-- This constraint ensures that the foreign key of table "staff"
-- correctly references the primary key of table "supervisor"
ALTER TABLE staff ADD CONSTRAINT fk2_staff_to_supervisor FOREIGN KEY(fk2_staffId) REFERENCES supervisor(staffId);
-- Alter table to add new constraints required to implement the "staff_to_venue" relationship
-- This constraint ensures that the foreign key of table "staff"
-- correctly references the primary key of table "venue"
ALTER TABLE staff ADD CONSTRAINT fk1_staff_to_venue FOREIGN KEY(fk1_venueId) REFERENCES venue(venueId);
-- Alter table to add new constraints required to implement the "act_stage" relationship
-- This constraint ensures that the foreign key of table "act"
-- correctly references the primary key of table "stage"
ALTER TABLE act ADD CONSTRAINT fk3_act_to_stage FOREIGN KEY(fk3_stageId) REFERENCES stage(stageId);
enter code here
--------------------------------------------------------------
-- End of DDL file auto-generation
--------------------------------------------------------------
は 'クエリのコードhere'ラインの一部を入力あなたは実行していますか? –
膨大な数のコードを投稿する代わりに、問題の原因となるビットを投稿する必要があります。これらの退屈な定型文の列はすべて、あなたの同僚があなたのコードを理解しやすくします(私はそれは疑いますが)。しかし、確かにそれはあなたの問題を見つけるためにそれを使用するための多くの困難になります。さらに、再現性のあるテストケースで集中的な問題を策定することは、あなたのためには良い練習です.SQLを学ぶのに役立ち、結局のところ質問を投稿することなく問題を解決することができます。 – APC
推奨されているように[最小、完全、および検証可能な例](https://stackoverflow.com/help/mcve)を作成し、写真を投稿しないでください(推奨されています)が、スクリプトを実行して出力を問題はそれだけで解決します。 – miracle173