반응형
------------------------------------------
--tablespace
------------------------------------------
--생성
CREATE TABLESPACE kimtest
DATAFILE '$ORACLE_BASE/oradata/green/kimtest.dbf' SIZE 50M AUTOEXTEND ON NEXT 5M;
--수정
ALTER DATABASE DATAFILE '$ORACLE_BASE/oradata/green/cmsdemo.dbf' AUTOEXTEND ON NEXT 10M MAXSIZE 10000M;
--삭제
DROP TABLESPACE kimtest INCLUDING CONTENTS;
--이동 (table을 tablespace 이동
ALTER INDEX 인덱스_이름 REBUILD TABLESPACE 옮길_테이블스페이스_이름;
--보기 (system 전체 tablespace)
SELECT tablespace_name, file_name, bytes
FROM dba_data_files;
--보기 (유저 table 목록 보기)
SELECT * FROM tab;
------------------------------------------
--user
------------------------------------------
--생성
CREATE USER kimtest IDENTIFIED BY kimtest DEFAULT TABLESPACE kimtest;
--권한주기
GRANT CONNECT, RESOURCE, CREATE TABLE TO kimtest;
--삭제(include user's tables)
DROP USER kimitest cascade;
--보기 (oracle server 접속 유저 보기)
select * from v$session where type = 'USER'
------------------------------------------
--Exporting & Importing
------------------------------------------
--Database
# exp system/manager file=wcms4.dmp full=y log=wcms4.log
(compress=y grants=y rows=y)
(rows=n : only schema backup)
# imp system/manager file=wcms4.dmp full=y commit=y
(grants=y rows=y)
--User Object
# exp system/manager file=wcms4.dmp owner=wcms4
# imp system/manager file=wcms4.dmp fromuser=wcms4 touser=wcms4 commit=y
(full=n grants=y rows=y)
--Tablespace
# exp system file=wcms4_1.dmp tablespaces=wcms4
# imp system file=wcms4_1.dmp tablespaces=kimi fromuser=wcms4 touser=kimi
# imp system file=jongno-wcms4-20040202.dmp fromuser=cmsuser touser=jongnoweb
------------------------------------------
--Oracle 시작과 종료
------------------------------------------
-- # lsnrctl start
-- # dbshut
-- # sqlplus /nolog
-- SQL> connect /as sysdba
-- SQL> startup
-- SQL> shutdown immediate
------------------------------------------
------------------------------------------
--Table
------------------------------------------
-- 속성보기
DESC MYTABLE;
-- 현재 사용자의 테이블 스페이스와 테이블 보기
select tablespace_name, table_name from tabs;
기타
◆ DB에 있는 모든 Table 이름보기
select table_name from user_tables
◆ Table의 Primary Key 찾기
select * from user_ind_columns where table_name = 'CodeTable'
◆ 서로 연결되는 Key를 찾는 방법
select constraint_name, constraint_type, r_constraint_name
from user_constraints where table_name = 'TABLE_NAME
◆ Constraint 확인
select table_name, constraint_name, constraint_type
from user_constraints
where table_name in ('DEPARTMENT','EMPLOYEE');
◆ Parameter정보 보기 (한/영코드값, 버젼정보등을 볼수있다.)
select * from nls_database_parameters
반응형
'Tip & Tech > Both | Other' 카테고리의 다른 글
PHP URL file-access is disabled in the server configuration 오류가 나타날때.. (0) | 2010.10.20 |
---|---|
오라클 instant client 설치 법 (0) | 2010.10.20 |
오라클 index로 잡힌 pk 삭제 법. (0) | 2010.10.20 |
오라클 테이블 스페이스 만들기. (0) | 2010.10.20 |
MySQL Dump & Restore (0) | 2010.10.20 |