Skip to content
Keep Learning Keep Living
Keep Learning Keep Living
Keep Learning Keep Living

ORA-00942: table or view does not exist and sequences as default value

Mustafa, 2019-07-232020-07-05

Hello,

after 12c or above we are able to set sequence’s nextval as the default value of an ID column. One of my customer started to complain about the ORA 00942 (table or view does not exist) error even if they have all necessary privileges on the table. After a quick investigation I realized that real error is not related with the table but the sequence.

Oracle PL/SQL
1
2
3
create sequence seq_tmp;
 
create table tmp (id number default on null seq_tmp.nextval, my_Data varchar2(10));

this is the sample code, I just assign seq_tmp as default value of tmp table. Now I create a user to test:

Oracle PL/SQL
1
2
3
create user test_user identified by test_user;
grant connect to test_user;
grant all on tmp to test_user;

as you can see I give all privileges on tmp table to test_user. now lets try to do some inserts with test_user:

Oracle PL/SQL
1
2
3
4
5
6
7
SQL> select * from mustafa.tmp;
 
no rows selected
 
SQL> insert into mustafa.tmp values (1, 'test row1');
 
1 row created.

so far so good. I provide all necessary value of the table and used my value as ID not the sequence. so let’s continue:

Oracle PL/SQL
1
2
3
4
5
SQL> insert into mustafa.tmp values (null, 'test row2');
insert into mustafa.tmp values (null, 'test row2')
          *
ERROR at line 1:
ORA-00942: table or view does not exist

viola! I use null as the value of ID which means sequence have to generate new id data but our insert statement got the ORA 00942. When I see this for the first time, I thought user doesn’t have necessary privileges on tmp table but now I’ve already known that user has privileges. Actually there is a small hint at this error! if you check, you can see that Oracle marks the error point with a star and it is under the “into” keyword, “o” if we want to be precise but if you really don’t have insert privilege on the table it would be marking table name:

Oracle PL/SQL
1
2
3
4
5
SQL> insert into mustafa.bla_bla_table_which_is_not_exist values(1);
insert into mustafa.bla_bla_table_which_is_not_exist values(1)
                    *
ERROR at line 1:
ORA-00942: table or view does not exist

as you can see star is under the first letter of the table name. anyway, if we continue to try inserting:

Oracle PL/SQL
1
2
3
4
5
SQL> insert into mustafa.tmp (my_data) values ( 'test row2');
insert into mustafa.tmp (my_data) values ( 'test row2')
          *
ERROR at line 1:
ORA-00942: table or view does not exist

all the combinations of insert statements will be fail when it needs to use the sequence. so let’s use sequence directly:

Oracle PL/SQL
1
2
3
4
5
SQL> insert into mustafa.tmp values (mustafa.seq_tmp.nextval, 'test row2');
insert into mustafa.tmp values (mustafa.seq_tmp.nextval, 'test row2')
                                        *
ERROR at line 1:
ORA-00942: table or view does not exist

error again and now we can see that our little star is under the sequence name! So real missing privilege is select on the sequence. after running: grant select on seq_tmp to test_user; all is fine and everything is working.

Don’t forget the sequences 🙂

12c 18c 19c Development default on nullora-00942sequence as defaulttable or view does not exists

Post navigation

Previous post
Next post

Comment

  1. Phong says:
    2023-06-29 at 12:11

    Seem so many error will show this code “ORA-00942: table or view does not exist”. In my case, cause the sequense of table config wrong and hibernate cannot insert value.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How to call HTTPS Url Without SSL Wallet in 19c
  • Is Table Unnecessary for Pipelined Function
  • Password Rollover Time in Seconds
  • PDB Syncronization Issue
  • How to limit DB Link Connection Timeout
  • Cloud Base Database Service
  • 29th of February and interval
  • How to Copy Local Files to Oracle Object Storage

Recent Comments

  • Mustafa on How to call HTTPS Url Without SSL Wallet in 19c
  • Накрутка авито on How to call HTTPS Url Without SSL Wallet in 19c
  • Mustafa on Cloud Base Database Service
  • Raja on Cloud Base Database Service
  • Mustafa on Refreshable PDB and ORA-17627: ORA-12578: TNS:wallet open failed

Categories

  • 11g
  • 12c
  • 18c
  • 19c
  • 21c
  • 23ai
  • Administration
  • Cloud
  • Compression
  • Development
  • Materialized View
  • Multi-tenant
  • Performance
  • Security
  • SQL / PLSQL
  • Uncategorized
  • Undocumented
  • Useful Scripts

Archives

  • April 2025
  • November 2024
  • July 2024
  • April 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • October 2021
  • September 2021
  • August 2021
  • April 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • July 2019
  • June 2019
  • May 2019
  • March 2019
  • February 2019
  • June 2018

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

RSS Follow This Blog

  • How to call HTTPS Url Without SSL Wallet in 19c
  • Is Table Unnecessary for Pipelined Function
  • Password Rollover Time in Seconds
  • PDB Syncronization Issue
  • How to limit DB Link Connection Timeout
  • Cloud Base Database Service
  • 29th of February and interval
  • How to Copy Local Files to Oracle Object Storage
  • Guid vs Sequences
  • Refreshable PDB and ORA-17627: ORA-12578: TNS:wallet open failed

Archives

  • April 2025
  • November 2024
  • July 2024
  • April 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • October 2021
  • September 2021
  • August 2021
  • April 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • July 2019
  • June 2019
  • May 2019
  • March 2019
  • February 2019
  • June 2018

RSS Follow This Blog

  • How to call HTTPS Url Without SSL Wallet in 19c
  • Is Table Unnecessary for Pipelined Function
  • Password Rollover Time in Seconds
  • PDB Syncronization Issue
  • How to limit DB Link Connection Timeout
  • Cloud Base Database Service
  • 29th of February and interval
  • How to Copy Local Files to Oracle Object Storage
  • Guid vs Sequences
  • Refreshable PDB and ORA-17627: ORA-12578: TNS:wallet open failed
RSS Error: A feed could not be found at `http://www.mywebsite.com/feed/`; the status code is `200` and content-type is `text/html; charset=UTF-8`
©2025 Keep Learning Keep Living | WordPress Theme by SuperbThemes