SQL-Union primary key

Source: Internet
Author: User

The Union primary key sets two or more fields in the table as the primary key. Then, the value combination of these fields is used as the primary key value. The value of this primary key is unique in the data table and the primary key index is added.


This is understandable.
For example, there are many fields in your order table. Generally, you only need to have an order number bill_no as the primary key. However, it is required that the order number be supplemented and the same order number be used, in this case, you cannot use the order number separately because there are duplicates. Then you can use the order serial number bill_seq as the difference. Set bill_no and bill_seq to the Union primary key. Even if bill_no is the same, different bill_seq is also possible.
In some cases, you can dynamically combine bill_no and bill_seq to obtain the ID, which facilitates the query operation.

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.