Oracle table structure and table content difference comparison

Source: Internet
Author: User

Oracle table structure and table content difference comparison

There are three sets of operations in Oracle, and they will set the left and right select result sets.

    • Union and set
    • Intersect intersection
    • Minus difference Set
Suppose there are two tables Student_a and Student_b
Create Tablestudent_a (IDVARCHAR2( $) not NULL, nameVARCHAR2( -), age Number, SexVARCHAR2(2)  ); Insert  intostudent_a (ID, name, age, Sex)Values('1','Bobo', -,'1'); Insert  intostudent_a (ID, name, age, Sex)Values('2','Sisi', in,'2'); Commit; Create TableStudent_b (IDVARCHAR2( $) not NULL, nameVARCHAR2( -), age Number, ClazzVARCHAR2( $)  ); Insert  intostudent_b (ID, name, age, Clazz)Values('1','Bobo', -,'1'); Insert  intostudent_b (ID, name, age, Clazz)Values('2','Sisi', in,'2'); Insert  intostudent_b (ID, name, age, Clazz)Values('3','Kiki', -,'1'); Commit;
As follows:

Compare two table structure difference statements:

Note that the following parentheses can not be saved, because it is calculated from left to right, if you omit the calculation formula is not the same oh, we can do their own brain repair.

(  SELECTcolumn_name fromUser_tab_columnsWHEREtable_name= 'student_a'minusSELECTcolumn_name fromUser_tab_columnsWHEREtable_name= 'Student_b')UNION(  SELECTcolumn_name fromUser_tab_columnsWHEREtable_name= 'Student_b'minusSELECTcolumn_name fromUser_tab_columnsWHEREtable_name= 'student_a')

The result diagram is as follows:

Compare two table content statements:

Note that the following parentheses can not be saved, because it is calculated from left to right, if you omit the calculation formula is not the same oh, we can do their own brain repair.

(  Select*from  student_a  minus   Select *  from   student_b) UNION (  SELECT*from  student_b  minus     SELECT*from  student_a)
The result diagram is as follows:

When comparing content, it is not concerned with whether the field name is different, it only cares about the type and value of the field.

Oracle table structure and table content difference comparison

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.