TRUNCATE Synonym & ORA-00942

Source: Internet
Author: User

colleagues can query the data in the table, but when truncate this table hold ORA-00942: The table or view does not exist

The beginning thought is the table name writes has the question, but later discovered that he deletes is not the table, but is a synonym (synonym)

It is not possible to use truncat for synonyms synonym.

Connected to Oracle Database 11g Enterprise Edition release 11.2.0.1.0
Connected as Scott

Sql> SELECT COUNT (1) from t_emp;

COUNT (1)
----------
3

sql> TRUNCATE TABLE t_emp; S

TRUNCATE TABLE T_emp

ORA-00942: Table or view does not exist

Sql> SELECT s.object_name,s.object_type,s.status from user_objects S WHERE s.object_name= ' t_emp ';

object_name object_type STATUS
--------------------       -------------------         -------
T_emp synonym VALID

sql> SELECT dbms_metadata.get_ddl (' synonym ', ' t_emp ') TEXT from dual;

TEXT
--------------------------------------------------------------------------------

CREATE OR REPLACE synonym "SCOTT". " T_emp "for" SCOTT "." TEST2 "

sql> TRUNCATE TABLE TEST2;

Table truncated

Sql> SELECT COUNT (1) from t_emp;

COUNT (1)
----------
0

Sql>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.