'SQL'에 해당되는 글 4건
- 2009/04/26 [Oracle sql] 전각문자 공백(Trailing Space)제거하기
- 2009/01/14 [Oracle] 쿼리 조회결과를 파일로 저장 - Oracle SPOOL Command
- 2008/07/15 [Oracle] PL/SQL RowID 사용하기 (ORACLE 테이블 레코드의 유일한 키로 사용)
- 2008/06/25 [SQL] SQL 쿼리문(SELECT)에서 상위 몇개만을 추출(TOP N)하기 (2)
테이블 레코드의 데이터에 공백 문자가 2bytes 전각문자로 기록되어 있는 경우,
Trailing space를 제거하기 위해 trim()함수를 사용해도 제거되지 않는다.
오라클에서는 전각문자를 그에 상응하는 single byte 문자로 치환해 주는 내장함수를
제공한다.
이 함수를 사용하는 경우 2byte로 된 영문자, 숫자, 공백 등이 모두 1byte문자로 치환된다.
to_single_byte()
(참고) 반대로, single byte를 multi byte문자로 치환하려면 to_multi_byte() 함수를 사용하면 된다.
2009/01/14 10:11
[Oracle] 쿼리 조회결과를 파일로 저장 - Oracle SPOOL Command
2009/01/14 10:11 in Development/Database

오라클에서는 쿼리 조회결과를 파일로 저장할 수 있는 기능을 제공한다.
다음과 같이 SPOOL Command를 사용하면 된다.
다음과 같이 SPOOL Command를 사용하면 된다.
2008/07/15 01:49
[Oracle] PL/SQL RowID 사용하기 (ORACLE 테이블 레코드의 유일한 키로 사용)
2008/07/15 01:49 in Development/iBatis

rowid 요넘한번 써보려고 삽질하다가 알아낸 큰 수확.
iBatis SqlMap에 ROWID 타입한번 써보려다가 까칠한 타입캐스팅 문제때문에 해결 방법을 찾다가
꽤 괜찮은 함수를 찾았다.
ROWID 타입은 ORACLE Function ROWIDTOCHAR() 을 통해 VARCHAR형으로 변환이 가능하다!!!!
.....................
오라클에서는 단일 레코드를 유일하게 식별할 수 있는 특수한 형태의 레코드 필드를 제공한다.
한 레코드의 유일한 키가 필요한 경우 RowId를 사용할 수 있다.
Oracle DataType : ROWID
Java Class : oracle.sql.ROWID
관련 JAR 파일 : ojdbc14.jar .......
-----------------------------------------------------
PL/SQL Rowid
Fixed-length binary.
Pseudocolumn of a table.
A DESCRIBE or SELECT * FROM MY_TABLE will not show the rowid;
a SELECT rowid FROM MY_TABLE will show the hashed location.
Fastest possible access to a given row
Rowids do not change as long as the record exists.
Rowids can not be changed during an insert or update transaction.
Rowids can only be used to return a record.
Rowids will change when EXPORTED or IMPORTED
Extended Rowids use a base 64 encoding of the physical address for each row selected
Rowid Structure
BBBBBBBB.RRRR.FFFF
BBBBBBBB=Block
RRRR=Row within the Block
FFFF=File Number
확장된 Rowid Structure
select rowid
,substr(rowid,1,6) "OBJECT"
,substr(rowid,7,3) "FILE"
,substr(rowid,10,6) "BLOCK"
,substr(rowid,16,3) "ROW"
from myTable;
INSTANCE_ID OBJECT FIL BLOCK ROW
------------------ ------ --- ------ ---
AAABUeAAQAAACsjAAg AAABUe AAQ AAACsj AAg
ROWID 형변환 관련 오라클 Function
ROWIDTOCHAR(rowid) converts a rowid into a string.
CHARTOROWID('rowid_string') converts a string into a rowid
ROWID를 이용한 레코드 조회
select rowidtochar(rowid) as id from my_table
where rowid=chartorowid('AAABUeAAQAAACsjAAg')
참조URL : http://www.orafaq.com/forum/t/26409/0/
iBatis SqlMap에 ROWID 타입한번 써보려다가 까칠한 타입캐스팅 문제때문에 해결 방법을 찾다가
꽤 괜찮은 함수를 찾았다.
ROWID 타입은 ORACLE Function ROWIDTOCHAR() 을 통해 VARCHAR형으로 변환이 가능하다!!!!
.....................
오라클에서는 단일 레코드를 유일하게 식별할 수 있는 특수한 형태의 레코드 필드를 제공한다.
한 레코드의 유일한 키가 필요한 경우 RowId를 사용할 수 있다.
Oracle DataType : ROWID
Java Class : oracle.sql.ROWID
관련 JAR 파일 : ojdbc14.jar .......
-----------------------------------------------------
PL/SQL Rowid
Fixed-length binary.
Pseudocolumn of a table.
A DESCRIBE or SELECT * FROM MY_TABLE will not show the rowid;
a SELECT rowid FROM MY_TABLE will show the hashed location.
Fastest possible access to a given row
Rowids do not change as long as the record exists.
Rowids can not be changed during an insert or update transaction.
Rowids can only be used to return a record.
Rowids will change when EXPORTED or IMPORTED
Extended Rowids use a base 64 encoding of the physical address for each row selected
Rowid Structure
BBBBBBBB.RRRR.FFFF
BBBBBBBB=Block
RRRR=Row within the Block
FFFF=File Number
확장된 Rowid Structure
select rowid
,substr(rowid,1,6) "OBJECT"
,substr(rowid,7,3) "FILE"
,substr(rowid,10,6) "BLOCK"
,substr(rowid,16,3) "ROW"
from myTable;
INSTANCE_ID OBJECT FIL BLOCK ROW
------------------ ------ --- ------ ---
AAABUeAAQAAACsjAAg AAABUe AAQ AAACsj AAg
ROWID 형변환 관련 오라클 Function
ROWIDTOCHAR(rowid) converts a rowid into a string.
CHARTOROWID('rowid_string') converts a string into a rowid
ROWID를 이용한 레코드 조회
select rowidtochar(rowid) as id from my_table
where rowid=chartorowid('AAABUeAAQAAACsjAAg')
참조URL : http://www.orafaq.com/forum/t/26409/0/
2008/06/25 22:24
[SQL] SQL 쿼리문(SELECT)에서 상위 몇개만을 추출(TOP N)하기
2008/06/25 22:24 in Development/Database

SELECT 문을 이용하여 데이터를 조회할 때 상위 몇개의 데이터만을 조회할 수 있습니다.
이러한 기능은 RBMS 마다 문법에 차이가 있습니다.
> SQL Server :
SELECT TOP 10 name, email, phone
FROM userinfo
FROM userinfo
> ORACLE :
SELECT name, email, phone
FROM userinfo
WHERE ROWNUM <= 10
FROM userinfo
WHERE ROWNUM <= 10
> MySQL :
SELECT name, email, phone
FROM userinfo
LIMIT 10
FROM userinfo
LIMIT 10
Prev
Rss Feed