DB2 Modifying a table field

Source: Internet
Author: User
Tags db2

1: Delete field non-empty property

ALTER TABLE XXX ALTER COLUMN XXX drop NOT NULL

This feature requires a version of DB2 9.0 or more

2: Add field non-empty property
ALTER TABLE XXX ALTER COLUMN XXX set NOT NULL

3: Add a new field
ALTER TABLE XXX add column XXXX varchar (100)

4: Delete a field
ALTER TABLE XXX drop column XXX

5: Increase the length of the field
ALTER TABLE XXX ALTER COLUMN XXX SET data type varchar (100)

Attention:

1: The name of the field is not allowed to be modified (can only be deleted first and then added).

2: The length of the field is not allowed to be reduced.

3: Modification of the field type is not allowed (such as modifying Integer to varchar).

4: If you have to modify the situation in the previous three, you can only re-build the table (the first one has a simple method).

DB2 Modifying a table field

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.