'Oracle'에 해당되는 글 5건

  1. 2014.05.28 oracle 대소문자 구분없이 검색하기
  2. 2014.05.20 oracle 타입 - nvarchar2 varchar2
  3. 2014.05.20 oracle view
  4. 2014.05.20 oracle alter
  5. 2014.05.11 oracle sequence 명령어
프로그램 사용/oracle2014. 5. 28. 16:23

select * from music_db where lower(TITLE) like lower('%MAN%')
select * from music_db where upper(TITLE) like upper('%MAN%')

select * from music_db where lower(TITLE) like '%man%'
select * from music_db where upper(TITLE) like '%MAN%'

안됨
select * from music_db where TITLE like '%MAN%'
select * from music_db where title like '%man%'

일단. 검색 키워드는 대문자로 올지 소문자로 올지 모르니
무조건 upper나 lower를 해중야 하니
사용가능한 선택지는 실질적으로 두가지뿐이다.


[링크 : http://jhbench.tistory.com/323]

'프로그램 사용 > oracle' 카테고리의 다른 글

sql group by  (0) 2014.05.30
sql distinct  (0) 2014.05.29
oracle 타입 - nvarchar2 varchar2  (0) 2014.05.20
oracle view  (0) 2014.05.20
oracle alter  (0) 2014.05.20
Posted by 구차니
프로그램 사용/oracle2014. 5. 20. 23:32
오라클에는 varchar2 라는 타입을 주로 사용하지만
이녀석은 char[] 로 1바이트 문자열을 최대 4000 byte까지 저장할 수 있다.
물론 4000 바이트라는건 최대 선언 가능한 길이일뿐
varcahr2 타입으로 선언한다고 해서 가변으로 0~4000자를 입력할수 있는건 아니다.
(이렇게 자동으로 길이 해주면 얼마나 좋았을까 -_-)

아무튼 요즘은 바야흐로(?) 유니코드 시대이기에 문자열 역시 유니코드로 저장하게 되는데
DB에서도 varchar2와 같이 1byte 문자열이 아닌 2byte 문자열(UTF-8 / UTF-16)을 지원해야 하고
이녀석은 nvarchar2로 N이 하나 더 붙게 된다.


VARCHAR2 and VARCHAR Datatypes

The VARCHAR2 datatype stores variable-length character strings. When you create a table with a VARCHAR2 column, you specify a maximum string length (in bytes or characters) between 1 and 4000 bytes for the VARCHAR2 column. For each row, Oracle stores each value in the column as a variable-length field unless a value exceeds the column's maximum length, in which case Oracle returns an error. Using VARCHAR2 and VARCHAR saves on space used by the table.

For example, assume you declare a column VARCHAR2 with a maximum size of 50 characters. In a single-byte character set, if only 10 characters are given for the VARCHAR2 column value in a particular row, the column in the row's row piece stores only the 10 characters (10 bytes), not 50.

Oracle compares VARCHAR2 values using nonpadded comparison semantics.


NCHAR and NVARCHAR2 Datatypes

NCHAR and NVARCHAR2 are Unicode datatypes that store Unicode character data. The character set of NCHAR and NVARCHAR2 datatypes can only be either AL16UTF16 or UTF8 and is specified at database creation time as the national character set. AL16UTF16 and UTF8 are both Unicode encoding.

The NCHAR datatype stores fixed-length character strings that correspond to the national character set.

The NVARCHAR2 datatype stores variable length character strings.

When you create a table with an NCHAR or NVARCHAR2 column, the maximum size specified is always in character length semantics. Character length semantics is the default and only length semantics for NCHAR or NVARCHAR2.

For example, if national character set is UTF8, then the following statement defines the maximum byte length of 90 bytes:

CREATE TABLE tab1 (col1 NCHAR(30));

This statement creates a column with maximum character length of 30. The maximum byte length is the multiple of the maximum character length and the maximum number of bytes in each character. 
[링크 : http://docs.oracle.com/cd/B19306_01/server.102/b14220/datatype.htm

If you prefer to implement Unicode support incrementally, or if you need to support multilingual data only in certain columns, then you can store Unicode data in either the UTF-16 or UTF-8 encoding form in SQL NCHAR datatypes (NCHAR, NVARCHAR2, and NCLOB). The SQL NCHAR datatypes are called Unicode datatypes because they are used only for storing Unicode data.

[링크 : http://docs.oracle.com/cd/B28359_01/server.111/b28298/ch6unicode.htm]

'프로그램 사용 > oracle' 카테고리의 다른 글

sql distinct  (0) 2014.05.29
oracle 대소문자 구분없이 검색하기  (0) 2014.05.28
oracle view  (0) 2014.05.20
oracle alter  (0) 2014.05.20
oracle sequence 명령어  (0) 2014.05.11
Posted by 구차니
프로그램 사용/oracle2014. 5. 20. 16:08
view는 일종의 select sql 문을 저장해 두는 기능을 한다.

CREATE VIEW locations_view AS
   SELECT d.department_id, d.department_name, l.location_id, l.city
   FROM departments d, locations l
   WHERE d.location_id = l.location_id;

SELECT column_name, updatable 
   FROM user_updatable_columns
   WHERE table_name = 'LOCATIONS_VIEW';
 
[링크 : http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_8004.htm

어떻게 보면.. 게시판 소스에서 많이 보게 되는 서브쿼리 혹은 중첩쿼리의 기능인데
subquery / inline view 라고도 부르며 이녀석 역시 일종의 view 인 것이었다!!

Inline 뷰
인라인 뷰는 FROM 절에서 서브쿼리를 사용하여 생성한 임시 뷰이다. 인라인 뷰는 SQL 문이 실행되는 동안만 임시적으로 정의된다.
 
[링크 : http://radiocom.kunsan.ac.kr/lecture/oracle/what_is/view.html

[링크 : http://zetswing.com/bbs/board.php?bo_table=ORACLE_TIP&wr_id=9&page=2


+
mysql에서 view는 5.0.x 부터 지원한다.
[링크 : http://dev.mysql.com/doc/refman/5.0/en/views.html]

'프로그램 사용 > oracle' 카테고리의 다른 글

oracle 대소문자 구분없이 검색하기  (0) 2014.05.28
oracle 타입 - nvarchar2 varchar2  (0) 2014.05.20
oracle alter  (0) 2014.05.20
oracle sequence 명령어  (0) 2014.05.11
오라클 DDL 정리  (0) 2014.05.11
Posted by 구차니
프로그램 사용/oracle2014. 5. 20. 15:43
변경시에는 추가된 값이 있으면 안되는 경우도 있으니(date -> varchar2)
주의해서 사용해야 할 듯...

alter table tablename add (colname type ..) // 항목 추가하기
alter table tablename drop column // 항목 삭제하기
alter table tablename modify (colname newtype ..) // 변수형 바꾸기
alter table tablename rename column oldname to newname // 항목명 바꾸기(9iR2 이후) 

[링크 : http://majesty76.tistory.com/27]


'프로그램 사용 > oracle' 카테고리의 다른 글

oracle 타입 - nvarchar2 varchar2  (0) 2014.05.20
oracle view  (0) 2014.05.20
oracle sequence 명령어  (0) 2014.05.11
오라클 DDL 정리  (0) 2014.05.11
오라클 10g용 시작/종료 스크립트  (0) 2014.04.11
Posted by 구차니
프로그램 사용/oracle2014. 5. 11. 23:13
음. 별 차이가 없군..

create sequence 했으니
drop sequence

[링크 : http://deuxism.tistory.com/27]

'프로그램 사용 > oracle' 카테고리의 다른 글

oracle view  (0) 2014.05.20
oracle alter  (0) 2014.05.20
오라클 DDL 정리  (0) 2014.05.11
오라클 10g용 시작/종료 스크립트  (0) 2014.04.11
oracle backup  (0) 2014.04.10
Posted by 구차니