I got a problem with oracle SQL. I just have installed and used for short time. When Im trying to create new table I got error ORA-00942 "Table or view does not exist". Im newbie at this, I was trying to find similar problem topics but I found just one and without actual links ("Table or view does not exist" on create table). At another topics I did not find anything useful in my case. I would be grateful for helping me with solution.
That commend I have tried, then the error occurred:
CREATE TABLE customer1 (
customer_id NUMBER(3) PRIMARY KEY,
customer_name VARCHAR(255) NOT NULL,
mobile_nr NUMBER(9) UNIQUE CHECK(LENGTH(mobile_nr)=9),
age NUMBER(3) CHECK(age>=18),
city_id NUMBER(4) REFERENCES cities(city_id)
);
Do you have in the database a table named cities? I expect not. That table is referenced in the foreign key: city_id NUMBER(4) REFERENCES cities(city_id). Thus, you must first create the table cities having the column city_id and a primary key constraint on it, then CREATE TABLE customer1. Generally, I prefer having scripts that create the tables with the create table SQL not including the constraints, and adding constraints after creating the tables with alter table add constraint SQL statements.