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
following statement:EXEC sp_tablesIt is the table information that filters out all records that table_type equals table in the result set.Other useful system functions--Read all table names in the librarySelect name from sysobjects where xtype= ' u '--Reads all column names of the specified tableSelect name from syscolumns where id= (select Max (id) from sysobjects where xtype= ' u ' and name= ' table name ')Get database table names and fieldsThe role of each system table in
SQL statement used to query fields of all INFORMIX data tables:
Select a. tabname, B. colname, B. coltype,Case B. coltypeWhen '0' then 'Char'When '1' then 'smallint'When '2' then' integer'When '3' then 'float'When '4' then 'smallfloat'When '5' then 'decimal'When '6' then 'serial'When '7' then 'date'When '8' then 'money'When '9' then 'null'When '10' then 'datetime
Label:Two kinds:1.select * FROM table 1, table 2, table 3 where table 1. field = Table 2. field and table 1. field = Table 3. FieldThis efficiency is smaller than the lower structure of simple data can be used2.select * FROM table 1 join table 2 on table 1. field = Table 2. field and join Table 3 on table 1. field = Table 3. FieldThis is good.
Questioner evaluation
2nd and join is wrong, should be join, no andHttp://zhidao.baidu.com/link?url=jI4ahWhPIbnq6gXcOZHWAeUPwSmO211KY
This problem was encountered by a friend who made an SSIS program to import data to txt. Then, use Oracle tools to import data to Oracle. However, when executing the variable step in SSIS, it is found that the output column name is completely different from the queried column name. For example, Schema_id is in the third column of the query, but 6th columns are output.
650) this. width = 650; "style =" he
I. List of databases1. List all librariesUse Master;goselect name,dbid from master.dbo.sysdatabases2. List only user librariesUse Master;goselect name,dbid from master.dbo.sysdatabases where dbid>4;Ii. list tables in a library1. List only the system tables in the library;Use Db_name;goselect name,xtype from sysobjects where xtype = ' s '2. List only the user data tables
II. Improving SQL statements
Many people do not know how SQL statements are executed in SQL Server, fearing that their written SQL statements will be misunderstood by SQL Server. Like what:
SELECT * FROM table1 where Name=zhangsan and TID > 10000
and implementation:
SELECT *
Tags: using ar sp data div art on BS sizePaged query statements that are used in different databases:Current page: CurrentPagePage Size: pagesize1. Oracle DatabaseSELECT * FROM (select A.*,rownum rn from (query_sql) A) where Rn Note: query_sql is a query SQL statement.OrSELECT * FROM (select RowNum rn,id from TABLENAME
Refer to this article: 51764100, thank the original authorThere are two tables, respectively, the "operator" and "documents", according to the different types of documents to classify the summary ( sales orders, sales return orders, the number of pens and amounts ), and displayed in the same table, do not want to be used as two times the method of query and merge
1. PhenomenaUsing cacti monitoring, there is a graph about the temporary tableYou can see that the temporary table being used is very large in active temp tables, and is maintained at about 400 during non-working hours. It feels very strange, so trace it down!2. ExploreFirst, verify that the cacti data is accurate and that the cacti data is known to be taken from the sys.dm_os_performance_counters counter DMV in S
number Employee Name Single SQL Public Dept getempbydeptno (int deptNo);}Writing test ClassesQuery department and employee single SQL@Testpublic void Onetomany () { Sqlsession sqlsession = Mybatisutil.getsession (); Ideptdao mapper = Sqlsession.getmapper (Ideptdao.class); Dept Dept = Mapper.getempbydeptno (1); SYSTEM.OUT.PRINTLN ("Department name" +dept.getdeptname ()); For (Emp emp:
Only one occurrence of each identical data in the Query data tableSELECT DISTINCT (order_no) from Ibsp_record_feeThe data in the Query data table decimal place is not 0SELECT * FROM Ibsp_pay_record PR where Pr.amountOrSELECT * FROM Ibsp_pay_record PR where pr.amount!= cast (pr.amount as Decimal (13,0))Delete table and ID sequenceTRUNCATE TABLE Ibsp_balance_account_data(Oracle)Oracle
SELECTTable name = D.name,Table Description = case when a.colorder=1 then IsNull (F.value, ') Else ' end,Field ordinal = A.colorder,Field name = A.name,Identification = case when ColumnProperty (A.id,a.name, ' isidentity ') =1 then ' √ ' Else ' end,Primary KEY = case when exists (SELECT 1 from sysobjects where xtype= ' PK ' and Parent_obj=a.id and name in (Select name from sysindexes WHERE indid in (SELECT indid from Sysindexkeys where id = a.id and colid=a.colid)) Then ' √ ' E LSE ' END,Type =
student namesBetween ... Expressed in a contiguous rangeSelect from where between 2 and 3 -- Student number 2 to 3 for all student namesIn means within a discontinuous rangeSelect * from where inch (3,1,6) -- Student number 1,3,6 all studentsLogical operators: And,or,notSelect * from where sid=3or sid=4-- student number 1,4 all studentsSELECT * FROM dbo. table_2 where Sid not in (3,4,5)--student number not 3,4,5 all studentsFuzzy query: A value u
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.