#!/bin/sh
mkdir /backup/archive/ORCL
mkdir /oracle/admin/ORCL/bdump
mkdir /oracle/admin/ORCL/cdump
mkdir /oracle/admin/ORCL/create
mkdir /oracle/admin/ORCL/pfile
mkdir /oracle/admin/ORCL/udump
mkdir /oradata/ORCL
setenv ORACLE_SID ORCL
echo Add this entry in the oratab: ORCL:/oracle/product/9.2.0:Y
/oracle/product/9.2.0/bin/orapwd file=/oracle/product/9.2.0/dbs/orapwORCL password=change_on_install
/oracle/product/9.2.0/bin/sqlplus /nolog @/oracle/admin/ORCL/scripts/CreateDB.sql
/oracle/product/9.2.0/bin/sqlplus /nolog @/oracle/admin/ORCL/scripts/CreateDBFiles.sql
/oracle/product/9.2.0/bin/sqlplus /nolog @/oracle/admin/ORCL/scripts/CreateDBCatalog.sql
/oracle/product/9.2.0/bin/sqlplus /nolog @/oracle/admin/ORCL/scripts/postDBCreation.sql |
connect SYS/change_on_install as SYSDBA
set echo on
spool /oracle/product/9.2.0/assistants/dbca/logs/CreateDB.log
startup nomount pfile="/oracle/admin/ORCL/scripts/init.ora";
CREATE DATABASE ORCL
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 3
MAXDATAFILES 100
DATAFILE '/oradata/ORCL/system01.dbf' SIZE 500M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/oradata/ORCL/temp01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
UNDO TABLESPACE "UNDOTBS1" DATAFILE '/oradata/ORCL/undotbs01.dbf' SIZE 500M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
CHARACTER SET KO16KSC5601
NATIONAL CHARACTER SET UTF8
LOGFILE GROUP 1 ('/oradata/ORCL/redo01.log') SIZE 102400K,
GROUP 2 ('/oradata/ORCL/redo02.log') SIZE 102400K,
GROUP 3 ('/oradata/ORCL/redo03.log') SIZE 102400K;
spool off
exit;
connect SYS/change_on_install as SYSDBA
set echo on
spool /oracle/product/9.2.0/assistants/dbca/logs/CreateDBFiles.log
CREATE TABLESPACE "INDX" LOGGING DATAFILE '/oradata/ORCL/indx01.dbf' SIZE 50M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
CREATE TABLESPACE "TOOLS" LOGGING DATAFILE '/oradata/ORCL/tools01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 320K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
CREATE TABLESPACE "USERS" LOGGING DATAFILE '/oradata/ORCL/users01.dbf' SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;
spool off
exit;
connect SYS/change_on_install as SYSDBA
set echo on
spool /oracle/product/9.2.0/assistants/dbca/logs/CreateDBCatalog.log
@/oracle/product/9.2.0/rdbms/admin/catalog.sql;
@/oracle/product/9.2.0/rdbms/admin/catexp7.sql;
@/oracle/product/9.2.0/rdbms/admin/catblock.sql;
@/oracle/product/9.2.0/rdbms/admin/catproc.sql;
@/oracle/product/9.2.0/rdbms/admin/catoctk.sql;
@/oracle/product/9.2.0/rdbms/admin/owminst.plb;
connect SYSTEM/manager
@/oracle/product/9.2.0/sqlplus/admin/pupbld.sql;
connect SYSTEM/manager
set echo on
spool /oracle/product/9.2.0/assistants/dbca/logs/sqlPlusHelp.log
@/oracle/product/9.2.0/sqlplus/admin/help/hlpbld.sql helpus.sql;
spool off
spool off
exit;
connect SYS/change_on_install as SYSDBA
set echo on
spool /oracle/product/9.2.0/assistants/dbca/logs/postDBCreation.log
@/oracle/product/9.2.0/rdbms/admin/utlrp.sql;
shutdown ;
startup mount pfile="/oracle/admin/ORCL/scripts/init.ora";
alter database archivelog;
alter database open;
alter system archive log start;
shutdown ;
startup pfile="/oracle/admin/ORCL/scripts/init.ora";
exit;
CREATE TABLESAPCE TS001
DATAFILE 'D:\TEST\DB1\DF001.DBF' SIZE 55M
DEFAULT STORAGE ( INITIAL 1024K NEXT 512K MAXEXTENTS 128 PCTINCREASE 0);
CREATE TABLESAPCE IS001
DATAFILE 'D:\TEST\DB1\IF001.DBF' SIZE 30M
DEFAULT STORAGE ( INITIAL 512K NEXT 256K MAXEXTENTS 128 PCTINCREASE 0);
SELECT TABLESPACE_NAME, FILE_NAME AS DATAFILE, (BYTES/1024) AS SZ_KB
FROM DBA_DATA_FILES;
CREATE USER BONSA01 IDENTIFIED BY BONSA01
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP;
SELECT USERNAME, DEFAULT_TABLESPACED, TEMPORARY_TABLESPACE, PROFILE
FROM DBA_USERS;
CREATE ROLE BONSA_ROLE NOT IDENTIFIED;
GRANT CREATE SESSION, CREATE TABLE, CREATE VIEW, ALTER ROLLBACK SEGMENT TO BONSA_ROLE;
SELECT ROLE FROM DBA_ROLES;
GRANT BONSA_ROLE TO BONSA01;
SELECT GRANTEE, GRANTED_ROLE
FROM DBA_ROLE_PRIVS;
CREATE TABLE DEPT (
DEPTNO NUMBER(2) NOT NULL,
DEPTNM VARCHAR2(14) NOT NULL,
LOC VARCHAR2(14) NULL,
CHARGE VARCHAR2(20) NULL
) TABLESPACE TS001
STORAGE ( INITIAL 1M NEXT 1M PCTINCREASE 0 );
ALTER TABLE DEPT ADD CONSTRAINT DEPT_PK PRIMARY KEY ( DEPTNO );
SELECT SEGMENT_NAME, ROUNT(INITIAL_EXTENT/1024, 0) INI_KB,
ROUND(NEXT_EXTENT/1024, 0) NXT_KB, ROUND(BYTES/1024, 0) TOT_KB,
PCT_INCREASE PCT, EXTENTS, TABLESPACE_NAME
FROM USER_SEGMENTS
WHERE SEGMENT_TYPE = 'TABLE';
SELECT TABLE_NAME, CONSTRAINT_NAME
FROM USER_CONSTRAINTS
WHERE CONSTRAINT_TYPE = 'P';
SELECT CONSTRAINT_NAME, R_CONSTRAINT_NAME, STATUS
FROM USER_CONSTRAINTS
WHERE CONSTRAINT_TYPE = 'R';
CREATE INDEX I_EMP01 ON EMP ( DEPTNO ASC ) TABLESPACE IS001;
SELECT SEGMENT_NAME, ROUND(INITIAL_EXTENT/1024, 0) INI_KB,
ROUND(NEXT_EXTENT/1024, 0) NXT_KB, ROUND(BYTES/1024, 0) TOT_KB,
PCT_INCREASE PCT, EXTENTS, TABLESPACE_NAME
FROM USER_SEGMENTS
WHERE SGEMENT_TYPE = 'INDEX';
SELECT TABLE_NAME, INDEX_NAME
FROM USER_INDEXES;
CREATE VIEW V_EMP AS
SELECT EMPNO, EMPNM, DEPTNO
FROM EMP;
SELECT OBJECT_NAME, OBJECT_TYPE, STATUS
FROM USER_OBJECTS
WHERE OBJECT_TYPE = 'VIEW';
$ORACLE_HOME/NETWORK/ADMIN/tnsnames.ora
BONSA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = BONSA))
CREATE PUBLIC DATABASE LINK H2U1
CONNECT TO BONSA01 INDENTIFIED BY BONSA01
USING 'BONSA';
CREATE SNAPSHOT LOG ON EMP
TABLESPACE TS001
STORAGE(INITIAL 1M NEXT 1M PCTINCREASE 0);
CREATE SNAPSHOT EMP
TABLESPACE TS002 STORAGE(MINEXTENTS 1 PCTINCREASE 0)
USING INDEX TABLESPACE IS002 STORAGE (MINEXTENTS 1 PCTINCREASE 0)
REFRESH FAST
START WITH SYSDATE NEXT TRUNC(SYSDATE) + 1 + (20/24) <- REFRESH 주기
AS SELECT * FROM EMP@BONSA; <-- 데이터베이스 링크명
- 강좌 URL : http://www.gurubee.net/lecture/3761
- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^
- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.