ORA-00942: table or view does not exist while creating the table - oracle

I am creating a table in an oracle database using a statement like this:
CREATE TABLE T_MY_NEW_TABLE (
ID VARCHAR2(10 char) not null,
VERSION NUMBER(4),
SOME_ID VARCHAR2(10 char) not null,
constraint PK_MY_NEW_TABLE primary key(ID)
);
This script usually runs fine. But sometimes I get the error: ORA-00942: table or view does not exist.
Which doesn't make any sense to me. What is the error supposed to mean?
I am creating a new table. The table that I am creating should not exist. But oracle want it to exist, so I can create it?
It must be something else. And only the error is misleading?
I tried to create a new table.
I expected the new table to be created.
Sometimes I am getting the error ORA-00942 instead of the created table.

Related

When I Create New Table from Oracle Sql Developer. I get this error

Error Messages:
ORA-00604: error occurred at recursive SQL level 1
ORA-00942: table or view does not exist
You're living a dangerous life.
Never, ever create anything in SYS (nor SYSTEM) schema.
Who knows what might be wrong ... maybe you dropped some SYS-owned object. Maybe there's a trigger which does "something" when you create a table.
There's nothing obvious in what you posted. Table, as is, creates normally:
SQL> show user
USER is "SCOTT"
SQL> create table table1
2 (id varchar2(20) not null,
3 ivoice varchar2(20) not null
4 );
Table created.
SQL>

Impossible to create trigger in a table with a reserved name in Oracle

I have a table named BLOB, and I can select, update, insert normally via SQL, but it's impossible to define a trigger for it, obviously the cause is the name.
In PL/SQL as a procedure, I work around the problem by creating a view which selects all the columns of the table, and using it in the body but it doesn't work on the table itself.
Does anyone have a solution? I cannot rename the table. Also using a synonym is out.
Structure of the table:
CREATE TABLE BLOB
(
BLOBID CHAR(7 BYTE) NOT NULL,
OGGETTO BLOB
)
The problem is related to the presence of a column of type BLOB in a table named BLOB, but only in PL/SQL environment (procs, triggers, ...)

Sequence is not hitting in Oracle Application Apex After creating app

I am trying to create a app in oracle apex. I have installed it in my pc(Ubuntu).
I have created a table and a sequence through sql command in apex.
Like
create table test (
test_id number primary key,
test_name varchar2(20) not null
);
and sequence like-
create sequence test_seq start with 1 increment by 1;
Now adding a single value in my table through sql-comand
insert into test values(test_seq.nextval, 'Test');
Okey runnig successfully.[1 row added]
But when i create a app using this table -
Please check it for details
Okey - Page creation successful but when i try to add data in it then it says -
ORA-01400: cannot insert NULL into ("WORKSPACE"."TEST"."TEST_ID")
Click here to See the attachment
So why this problem occurs?
I think you have not associated sequence to primary column of your table. Alter your table and then try to add data using app.
ALTER TABLE TEST
MODIFY (TEST_ID DEFAULT TEST_SEQ.NEXTVAL );
Ideally, you would create sequence first and then while creating table, you can define column default as follows,
CREATE TABLE TEST (
TEST_ID NUMBER DEFAULT TEST_SEQ.NEXTVAL NOT NULL PRIMARY KEY,
TEST_NAME VARCHAR2(20) NOT NULL
);
Try:
Insert into test
(Test_id,test_name)
Select test_seq.nextval, 'something'
From dual;
Commit;

create table query in oracle- ORA 00922

I am trying to create a table in oracle 11g, that should be created only the first time, as in if it doesn't exist. If it exists it should not create the table.
create table IF NOT EXISTS sample_temp
(
SFL_ID number(10) not null,
STM_ID number(10) not null,
FIL_ID number(10) not null,
SYSTEM_GENERATED_FL char null ,
SFL_DELETE_FL char not null,
SFL_VERSION_ID number(10) not null,
PTN_ID number(10) not null);
This gives an ORA- 00922 error, telling a syntax error near the words "if not". What am I doing wrong? Is 'if not exists' not supported in Oracle? then how should I go about doing it? I am actually trying to create this via jdbc.
Oracle does not support the IF NOT EXISTS syntax. The easiest solution would be to run another query to check whether table already exists in the schema of your database.
If you are connecting as a user orcl, and the table you are trying to create is going to be on the same schema, then you can do this
select count(*) from user_tables where table_name=upper('yourtable');
if the count returns 1, then you know that the table exists and you can skip the table creation process. Otherwise go ahead and create the table.
You can't use "if not exists" command recheck if table already exists or not. You can do one thing : you can use query USER_TABLES or DBA_TABLES to check if your table exists or not .If it exists then do what you want to do and if it doesn't exists then you can create a new one .
You can simply send the CREATE TABLE statement to the Oracle engine. If the table exists, this will return an error telling you the table already exists. If you need this for further processing in your code, you can just capture this error message.

Materialized view for different oracle schema results in ORA-1208

I want to create on commit materialized oracle view pointing to table from different schema within same database instance.
schema (BATCH):
CREATE TABLE "BATCH"."BATCH_CONFIG"
( "KEY" VARCHAR2(100 BYTE),
"VALUE" VARCHAR2(4000 BYTE),
"COMMENTS" VARCHAR2(4000 BYTE),
"UPDATED_BY" VARCHAR2(25 BYTE),
"UPDATED" TIMESTAMP (6),
CONSTRAINT "PK_BATCH_CONFIG" PRIMARY KEY ("KEY")
);
create materialized view log on batch_config;
grant all on batch_config to profile;
schema (PROFILE):
create materialized view mv_batch_config REFRESH FAST ON COMMIT
as select * from BATCH.batch_config;
Got Error:
SQL Error: ORA-12018: following error encountered during code generation for "PROFILE"."MV_BATCH_CONFIG"
ORA-00942: table or view does not exist
12018. 0000 - "following error encountered during code generation for \"%s\".\"%s\""
*Cause: The refresh operations for the indicated materialized view could
not be regenerated due to errors.
*Action: Correct the problem indicated in the following error messages and
repeat the operation.
What is the issue with ? I am able to view query by (from profile schema) select * from BATCH.batch_config
OK finally I got the solution.
I have to grant select on mview log also.
GRANT SELECT ON MLOG$_BATCH_CONFIG TO PROFILE;

Resources