2016-08-18 4 views
0

나는 두 테이블이 AB이라고 말합니다 (테이블 B은 이전 백업 테이블 A입니다). 둘 다 (두 테이블 모두에서) 열 중 하나가 동일한 열을 갖는 경우 LONG 데이터 유형입니다.2 긴 행을 비교 오라클 SQL

  1. 같은 ID하지만 서로 다른 RECORD하고,
  2. 같은 RECORD하지만 서로 다른 ID을 :

    Columns : ID and RECORD 
    

    이 나는 ​​테이블 (또는 같은 ID을하지 않을 수 있습니다) 그 결과가 제공해야 두 비교하려면 .

답변

0

오래 사용하기 전에 LONG에 대한 몇 가지 사실을 이해해야합니다.

LONG 값의 사용은 이러한 제한 사항이 적용됩니다 : 당신을 비교 한 모든 종류의 작업을 수행하는 동안 주변

1 A table can contain only one LONG column. 
2 You cannot create an object type with a LONG attribute. 
3 LONG columns cannot appear in WHERE clauses or in integrity constraints (except that they can appear in NULL and NOT NULL constraints). 
4 LONG columns cannot be indexed. 
5 LONG data cannot be specified in regular expressions. 
6 A stored function cannot return a LONG value. 
7 You can declare a variable or argument of a PL/SQL program unit using the LONG data type. However, you cannot then call the program unit from SQL. 
8 Within a single SQL statement, all LONG columns, updated tables, and locked tables must be located on the same database. 
9 LONG and LONG RAW columns cannot be used in distributed SQL statements and cannot be replicated. 
10 If a table has both LONG and LOB columns, then you cannot bind more than 4000 bytes of data to both the LONG and LOB columns in the same SQL statement. However, you can bind more than 4000 bytes of data to either the LONG or the LOB column. 

IN ADDITION, LONG COLUMNS CANNOT APPEAR IN THESE PARTS OF SQL STATEMENTS: 

1 GROUP BY clauses, ORDER BY clauses, or CONNECT BY clauses or with the DISTINCT operator in SELECT statements 
2 The UNIQUE operator of a SELECT statement 
3 The column list of a CREATE CLUSTER statement 
4 The CLUSTER clause of a CREATE MATERIALIZED VIEW statement 
5 SQL built-in functions, expressions, or conditions 
6 SELECT lists of queries containing GROUP BY clauses 
7 SELECT lists of subqueries or queries combined by the UNION, INTERSECT, or MINUS set operators 
8 SELECT lists of CREATE TABLE ... AS SELECT statements 
9 ALTER TABLE ... MOVE statements 
10 SELECT lists in subqueries in INSERT statements 

작품은 CLOB 한 열이있는 뷰를 생성하고 모든 작업을 수행하는 것입니다. 아래를 확인하십시오.

create table B(ID number, RECRD long) 

create table A(ID number, RECRD long) 

select recrd from A where recrd = '12345' 

--This will throw error "illegal use of LONG datatype 

WORK AROUND : 

SQL> CREATE TABLE A_view 
    AS 
    SELECT id, 
      TO_LOB(recrd) AS recrd 
    FROM A; 


SQL> CREATE TABLE B_view 
    AS 
    SELECT id, 
      TO_LOB(recrd) AS recrd 
    FROM B; 


select * from A_view where DBMS_LOB.substr(recrd) = '12345' 


drop table a; 

drop table b; 

drop table a_view; 

drop table b_view;