DB2-alter append/delete/Reset column operation organization

Source: Internet
Author: User

DB2-alter append/delete/Reset column operation finishing 1. add field alter table name add field name type Demo: 1 alter table table_name add column_test VARCHAR (50); 2. change Field type alter table name alter column field name set data type Demo: 1 alter table table_name alter column column_test set data type VARCHAR (3); note: there are operation restrictions on changing the field type. you can change the field to a value greater than the previous type length. to change it to a smaller value, you must drop the original column and add it again. for example, if I want to change the column of A Varchar (50) to Varchar (30), the above SQL statement cannot be used successfully. in addition, to change to different types, you also need to drop column first. 3. remove the field alter table Name drop column field name Demo: 1 alter table table_name drop column column_test; Note: After dropping the field, the table query/insert operation may fail, you need to execute the reorg command. reorg table table_name; 4. add default value for field alter table name alter column field name set default value Demo: 1 alter table table_name alter column column_test set default 'value'; 5. add the field Demo with the default value: 1 alter table table_name add column column_test vachar (20) not null with default 'value'; 6. set the default field time to the current time Demo: 1 alter table table_name alter column column_test set default current date;

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.