오라클 팁 (버젼정보)
작성자 관리자 작성시간 2004-09-18 01:24:25
 

◆ DB에 있는 모든 Table 이름보기

select table_name from user_tables

◆ Table의 Primary Key 찾기

select * from user_ind_columns where table_name = 'CodeTable'

◆ 인수전달

select * from user_ind_columns where table_name = '&1'
===>; save key

SQL> start key CodeTable

◆ 서로 연결되는 Key를 찾는 방법

select constraint_name, constraint_type, r_constraint_name
from user_constraints where table_name = 'TABLE_NAME

◆ TABLE 구조 보기

DESC TABLE_NAME

◆ Constraint 확인

select table_name, constraint_name, constraint_type
from user_constraints
where table_name in ('DEPARTMENT','EMPLOYEE');

◆ 테이블 COPY 하기

create table emp_41
as
select id, last_name, userid, start_date from s_emp
where dept_id = 41;

===> where절에 엉뚱한 조건을 주면 emp_41이란 이름으로 테이블이 만들어진다.

◆ 선택한 Row만큼만 보여주기

select * from tmp_table
where rownum <= 100


---> 이렇게 하면 데이터가 10000건이 있더라도, 1~100건만 보여주게 된다.


◆ 오라클의 모든 유저 보기

select * from all_users

◆ Parameter정보 보기 (한/영코드값, 버젼정보등을 볼수있다.)

select * from nls_database_parameters
---> 이때, NLS_CHARACTERSET의 Value가 KO16KSC5601 이면 한글...
US7ASCII 이면 영문이다. ---> regedit에서 편집하면 간단히 해결.

◆ Space 있는 값을 Null로 비교

RTRIM(a.ymd_myun) IS NULL

◆ Desc명령으로 Table구조 보는 효과와 같은 방법

SELECT column_name, data_type, data_length, nullable FROM cols
WHERE table_name = 'YTB_CARCOM'
---> 반드시 테이블명은 대문자 이어야 한다.

◆ Function Script 보는 방법.

select text from user_source where name = 'FUNCTION_NAME'

◆ 요일 찾는 방법.

select TO_CHAR(sysdate,'D') from dual


목록 | 입력 | 수정 | 답변 | 삭제