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