sql query to compare two tables in different databases
sql query to compare two tables in different databases
Read about sql query to compare two tables in different databases, The latest news, videos, and discussion topics about sql query to compare two tables in different databases from alibabacloud.com
Two tables linked to different libraries in the same server
This approach is limited to databases on the same server.I. Establishment of two databases, library a (table a) and Library B (table B).Second, to two libraries to assign the same account permissions.Use the following statement when querying:
The
This SQL statement can query for two different structures of different tables and can tell which records belong to which table
has two tables
The Table1 structure is as follows
ID Title Content
The table2 structure is as follows
. Method Three: Using connection query Connection queries include: 1. Self-connect (join equals inner JOIN): Query result is data that exists on both sides 2. Left join to the left join: return all data on the right, return to the back, null not present 3. Right join: Return all data on the right, return on left, no null 4. Fully connected full join: Returns if one of the
SQL statement Optimization-query different rows of the two tables NOT IN, NOT EXISTS, Join query Left Join, existsleft
In actual development, we often need to compare the differences between two or more
sides2. Left join to the left join: return all data on the right, return to the back, null not present3. Right join: Return all data on the right, return on left, no null4. Fully connected full join: Returns if one of the tables exists and the other does not exist as Nul SELECT d.* from Depart_info D left joins User_info u on d.pid = U.pid WHERE u.pid is NULL;Test time is around 0.001sSummarize:1, for a small amount of data exists and in the same,
Statement This SQL statement can query two different fields of different structures and can tell which records belong to which table
has two tables
The Table1 structure is as follows
ID Title Content
The table2 structure is as follows
ID content Bigclass Smallclass
name, the table name of the reference table and the corresponding key name, the following is divided into multi-step query):SELECT * from user_constraints c where c.constraint_type = ' R ' and c.table_name = table to queryQuery the column name of the FOREIGN KEY constraint:SELECT * from User_cons_columns cl where cl.constraint_name = FOREIGN key NameQuery the column name of the key referencing the table:SELECT * from User_cons_columns cl where cl.con
Label:MS SQL Server 1, querying all tables select [ID], [name] from [sysobjects] where [type] = ' u ' ORDER BY [name] 2, querying all Databases 3, select [Name] F ROM [sysdatabases] ORDER BY [Name] Query table field select [Name] from [syscolumns] where [name] = ' tablexxx ' ORDER by [Colid] Oracle 1. Find all indexes
Different databases: oracle mysql SQL Server DB2 infomix sybase paging query statement, infomixsybase
Paging query statements used in different databases:
Current page: currentpagePage
Straint_type = ' U ' and au.table_name = table to query 4. Find the foreign key of the table (including the name, the table name of the reference table and the corresponding key name, the following is divided into multi-step query): SELECT * from user_constraints c where c.constraint_type = ' R ' and c.table_name = table to query
If the structures of multiple tables are different, it seems impossible to query the results of multiple tables together! For example, Table
If the structures of multiple tables are different, it seems impossible to
Query for SQL statements that all databases consume disk space size:
Copy Code code as follows:
Select Table_schema, concat (Truncate (SUM (data_length)/1024/1024,2), ' MB ') as Data_size,Concat (Truncate (SUM (index_length)/1024/1024,2), ' MB ') as Index_sizeFrom Information_schema.tablesGROUP BY Table_schemaORDER BY data_length Desc;
-- Delete Table----------------------------------------------------------------------------------To add a constraint:ALTER TABLE Table name ADD CONSTRAINT constraint name constraint type specific constraint description1. The naming rules for constraint names are recommended in the form of constraint type _ constraint name.----------------------------------------------------------------------------------To delete a constraint:There are two ways to add a constraint to a specified tabl
name of the reference table and the corresponding key name, the following is divided into multi-step query):SELECT * from user_constraints c where c.constraint_type = ' R ' and c.table_name = table to queryQuery the column name of the FOREIGN KEY constraint:SELECT * from User_cons_columns cl where cl.constraint_name = FOREIGN key NameQuery the column name of the key referencing the table:SELECT * from User_cons_columns cl where cl.constraint_name = f
SqlCommand object, so you only need to replace the linefeed in the preceding SQL command with a space to form a string and assign it to the CommadnTest attribute of the SqlCommand object, then execute the command. It seems that I have not used this method to create a database. However, if you have enough user permissions to connect to the database, there should be no problem !)
Additional reading:
Source: blog
Author: Yan Zedong
1,
Urgent !! How to compare the content of two tables in the database, delete the same data, and keep different data urgently !!! I would like to explain how to compare the data in two tables and query them one by one. If the data is
Urgent !! How to compare the content of two tables in the database, delete the same data, and keep different data urgently !!! I would like to explain how to compare the data in two tables and query them one by one. If the data is
Comparison of data table structure"Principle" uses the system table "sysobjects", "sysindexes", "Sysindexkeys", "syscomments", "Sysclumns", "systypes", "extended_properties", Compare the table structure in the database. (more system tables are involved.) Don't introduce them. directly on the code. )Code/*--Compare table structure differences for two
Emergency!! How to compare the contents of two tables in a database, delete the same data, and keep different data
URGENT Request!!!
Excuse me, how to compare the data in two tables. If the data is the same, check one article and delete it, if the data is
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.