Primary Key change of Table Structure

Source: Internet
Author: User

Requirement: Add a column location_no based on the existing table structure to make it one of the primary keys;
Add a non-primary key column only_allow;

Solution:
Step 1) Add two columns first
Alter table ht_limit_lot2_tab
Add
(Location_no varchar2 (50 ),
Only_allow varchar2 (5 ));

Step 2) default values for two columns
Update ht_limit_lot2_tab
Set location_no = '%', only_allow = 'false ';

Step 3) delete a primary key
Alter table ht_limit_lot2_tab
Drop primary key;

Step 4) Add a primary key.
Alter table ht_limit_lot2_tab
Add (constraint ht_limit_lot2_pk primary key (contract, customer_id, address_id, part_no, lot_no, location_no)
Using Index
Tablespace ifsapp_index
);

By foreveryday007 20060719.
Http://blog.csdn.net/foreveryday007/

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.