OCP-1Z0-New 051-61 question version-1

Source: Internet
Author: User
Tags dname

Question no: 1

Evaluate the SQL statement:

Truncate table dept;

Which three are true about the SQL statement? (Choose three .)

A. It releases the storage space used by the table.

B. It does not release the storage space used by the table.

C. You can roll back the deletion of rows after the statement executes.

D. You can NOT roll back the deletion of rows after the statement executes.

E. An attempt to use DESCRIBE on the DEPT table after the TRUNCATE statement executes will display an error.

F. You must be the owner of the table or have delete any table system privileges to truncate the DEPT table

Answer: A, D, F

Answer:

Reference: http://docs.oracle.com/cd/E11882_01/server.112/e25494/general.htm#ADMIN11534

It is a DDL statement and cannot be rolled back D correct, C Error

A truncate statement also specifies whether space currently allocated for the table is returned to the containing tablespace after truncation. A is correct. B Error

You can truncate any table or cluster in your own schema. Any user who has the drop any table system privilege can truncate a table or cluster in any schema. F is correct.

Sys @ TESTDB> conn scott/tiger

Connected.

Scott @ TESTDB> select * from dept_new

2;

DEPTNO DNAME LOC

-------------------------------------

10 ACCOUNTING NEW YORK

20 RESEARCH DALLAS

30 SALES CHICAGO

40 OPERATIONS BOSTON

50 IT CHINA

60 CLERK BEIJING

6 rows selected.

Scott @ TESTDB> truncate table dept_new;

Table truncated.

Scott @ TESTDB> select * from dept_new;

No rows selected

Scott @ TESTDB> desc dept_new; desc will not report an error. E error.

Name Null? Type

----------------------------------------------------------------------------------------------------

Deptno number (2)

DNAME VARCHAR2 (14)

LOC VARCHAR2 (13)

Scott @ TESTDB> rollback; -- cannot rollback

Rollback complete.

Scott @ TESTDB> select * from dept_new; -- no return

No rows selected

Using TRUNCATE

You can delete all rows of the table using the TRUNCATE statement. For example, the following statement truncates the emp table:

Truncate table emp;

Using the TRUNCATE statement provides a fast, efficient method for deleting all rows from a table or cluster. a truncate statement does not generate any undo information and it commits immediately. it is a DDL statement and cannot be rolled back. a truncate statement does not affect any structures associated with the table being truncated (constraints and triggers) or authorizations. a truncate statement also specifies whether space currently allocated for the table is returned to the containing tablespace after truncation.

You can truncate any table or cluster in your own schema. Any user who has the drop any table system privilege can truncate a table or cluster in any schema.

Before truncating a table or clustered table containing a parent key, all referencing foreign keys in different tables must be disabled. A self-referential constraint does not have to be disabled.

As a TRUNCATE statement deletes rows from a table, triggers associated with the table are not fired. also, a TRUNCATE statement does not generate any audit information corresponding to DELETE statements if auditing is enabled. instead, a single audit record is generated for the TRUNCATE statement being issued.

A hash cluster cannot be truncated, nor can tables within a hash or index cluster be individually truncated. truncation of an index cluster deletes all rows from all tables in the cluster. if all the rows must be deleted from an individual clustered table, use the DELETE statement or drop and re-create the table.

The TRUNCATE statement has several options that control whether space currently allocated for a table or cluster is returned to the containing tablespace after truncation.

These options also apply to any associated indexes. when a table or cluster is truncated, all associated indexes are also truncated. the storage parameters for a truncated table, cluster, or associated indexes are not changed as a result of the truncation.

These TRUNCATE options are:

Drop storage, the default option, CES the number of extents allocated to the resulting table to the original setting for MINEXTENTS. Freed extents are then returned to the system and can be used by other objects.

Drop all storage drops the segment. in addition to the truncate table statement, drop all storage also applies to the alter table truncate (SUB) PARTITION statement. this option also drops any dependent object segments associated with the partition being truncated.

Drop all storage is not supported for clusters.

Note:

  • This functionality is available with Oracle Database 11g release 2 (11.2.0.2). truncate table emp drop all storage;

    Reuse storage specifies that all space currently allocated for the table or cluster remains allocated to it. for example, the following statement truncates the emp_dept cluster, leaving all extents previusly allocated for the cluster available for subsequent inserts and deletes:

    Truncate cluster emp_dept reuse storage;

Related Article

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.