In the Informix Environment, add fields to an existing data table and adjust the primary key constraint of the data table.

Source: Internet
Author: User
Tags informix

In the Informix Environment, add fields to an existing data table and adjust the primary key constraint of the data table.

 

 

 

In the Informix database environment, add fields to an existing data table and adjust the primary key constraint of the data table. The procedure is as follows:

 

(1) Add a field to an existing table:

 

SQL Syntax: ALTER TABLE table_name add column_name column_type optional_restriction;

For example, alter table x_user add zip_code integer default 1000;

Note: If the newly added field needs to be added to the primary key constraint and existing data in the original data table, the new field must have a default value. Otherwise, the Operation will fail.

 

(2) query the name of the primary key constraint of an existing table:

SQL Syntax: Select constrname from sysconstraints where constrtype = 'P'

And Tabid = (select Tabid from tables Ables where tabname = 'table _ name ');

 

(3) Drop primary key constraints for the original table:

SQL Syntax: ALTER TABLE table_name drop constraint primary key constraint name; // The value queried in (2)

 

(4) reset the primary key constraint:

SQL Syntax: ALTER TABLE table_name add constraint primary key (col_name1, col_name2,...) [constrain primary key constraint name];

// The primary key constraint name can be the original name, and the value queried in (2)

 

 

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.