Table in Oracle adds a discussion with a default value column (including 12C new features)

Source: Internet
Author: User

This is a question that I have always been concerned about.

11G about this problem has improved, to 12C more is a number of new features

For a discussion of the new features of 11G, refer to my blog http://blog.csdn.net/dbcrocodile/article/details/21170407

12C on this aspect is added on the new 11G feature.

Adding a column to the 11G and setting the default value does not make changes to the actual data in the table, but rather by marking the data dictionary

When we query, we do an operation like NVL () for the new column, and if it is NULL, the default value is returned.

However, look at the following statement

Sql> ALTER TABLE t add Mrdai number default 10000 NOT NULL;    Table altered.    elapsed:00:00:00.34  

In 11G, the new plus column must be a NOT NULL property, otherwise the attribute will not be implemented. will still cause large DDL transactions, and hang all operations on the table (including select).

If you do not understand the characteristics, it is easy to think that there are characteristics, and rushed to add, resulting in a very serious accident.

And in 12C, this feature has been strengthened again, we can not set the NOT NULL here, greatly reducing the possible error operation

See the following experimental process

CREATE table T, where more than 1 million rows of data.

Sql> Select COUNT (*) from T;  COUNT (*)----------   1454256

Add a column directly to the table (not set NOT NULL)

Sql> ALTER TABLE t add MRDAI1 number default 10000; Table altered. elapsed:00:00:00.03

The speed is swift. And, of course, as in 11G.

After the setting is complete, if it is a newly inserted row, in the default Value column, the data is actually inserted into the row


Table in Oracle adds a discussion with a default value column (including 12C new features)

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.