Simple DDL operations in db2

Source: Internet
Author: User


Simple DDL operation http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/index.jsp in db2? Topic =/com.ibm.db2.luw.admin.partition.doc/c0007201.html the link above is the IBM-DB2-API documentation *************************** **************************************** *************
Create table aa (aa decimal (18), bb varchar (18); remember reorg table aa after all DDL operations are completed; (reorganize the table structure) -- added the field alter table name add column field type. For example, alter table aa add column cc varchar (20); www.2cto.com -- changed the field name. Example: change aa to cc1. Add a new field cc, and then assign the value of aa to cc2. Delete aa and reorg table -- modify the field type alter table name alter field set data type; example: alter table aa alter bb set data type varchar (40); -- modify the length of a field (only large, not small) alter table name alter field set data type; example: alter table aa alter bb set data type varchar (40); www.2cto.com -- add the not null constraint to the field alter table name alter field set not null; example: alter table aa alter bb set not null; -- delete the not null constraint on the field. alter table name alter column field drop not null; example: alter table aa alter column bb drop not null; -- delete the field alter table Name drop column; for example, alter table aa drop column bb; -- copy the table structure and data create table cb_ba_CURRENCY like BASE_CURRENCY; insert into cb_ba_CURRENCY select * from BASE_CURRENCY; www.2cto.com -- ADD the unique constraint alter table employee add constraint newid unique (EMPNO, HIREDATE) -- delete the UNIQUE constraint alter table <table-name> drop unique <CONSTRAINT-name> -- ADD the primary key constraint alter table <name> add constraint <column_name> primary key <column_name> -- delete the PRIMARY KEY constraint alter table <table-name> DROP PRIMARY KEY

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.