|
ORACLE DATABASE À缳ġÇϱâ
DB ¸¦ ±ú²ýÇÏ°Ô ¹Ð¾î ¹ö¸®°í Àç ¼³Ä¡Çϰųª ¶Ç´Â DB±¸Á¶¸¦ º¯°æÇÒ ¶§ À¯¿ëÇÑ
Create Database µû¶óÇϱâ... (ÀÌ°Å ÇԺηΠµû¶óÇÏ´Ù À߸øÇÏ¸é ´ÙĨ´Ï´Ù)
---------------------------------------------------------------------
-----------
1. ±âÁ¸ µ¥ÀÌÅͺ£À̽º ¹é¾÷ ¹Þ±â
2. µ¥ÀÌÅͺ£À̽º »ý¼º ½ºÅ©¸³Æ® (crdb, crdb2.sql) ¼öÁ¤Çϱâ
3. Create Database
4. System View »ý¼º
5. µµ¿ò¸»°ú »ùÇà Å×ÀÌºí »ý¼º
6. ¹é¾÷ µ¥ÀÌÅÍ º¹¿ø
---------------------------------------------------------------------
-----------
1. ±âÁ¸ µ¥ÀÌÅͺ£À̽º ¹é¾÷ ¹Þ±â
¿ì¼± export ÅøÀÎ exp ¸¦ ÀÌ¿ëÇÏ¿© Àüü database ¸¦ ¹é¾÷ ¹Þ½À´Ï´Ù.
$ exp system/manager file=fullbackup.dmp full=y
±×¸®°í ±âÁ¸ÀÇ µ¥ÀÌÅÍÁß ±×´ë·Î »ç¿ëÇÒ µ¥ÀÌÅÍ ¶Ç´Â ¸¸¾à À缳ġ¿¡ ½ÇÆÐÇßÀ» ¶§¸¦
´ëºñÇؼ
±âÁ¸ÀÇ µ¥ÀÌÅ͸¦ ¸ðµÎ ¹é¾÷À» ¹Þ°í, ÇöÀçÀÇ ¼³Á¤µµ ¹é¾÷¹Þ¾Æ¾ß °ÚÁö¿ä.
SQL>spool bakdata.txt
SQL>select * from v$dba_users; - À¯ÀúµéÀÇ µðÆúÆ® Å×ÀÌºí½ºÆäÀ̽º, tempÅ×ÀÌ
ºí½ºÆäÀ̽º
SQL>select * from v$datafile; -- °¢°¢ÀÇ µ¥ÀÌÅÍÆÄÀÏÀÇ À§Ä¡¿Í Å©±â
SQL>select * from dba_tablespaces -- Å×ÀÌºí ½ºÆäÀ̽º Á¤º¸
SQL>select * from dba_data_files; -- Å×ÀÌºí ½ºÆäÀ̽º¿Í ±× ÆÄÀÏÀÇ ±¸¼ºÁ¤º¸
SQL>select * from dba_rollback_segs; -- ·Ñ¹é ¼¼±×¸ÕÆ® Á¤º¸
SQL>select * from v$log; -- redo log ÀÇ Á¤º¸
SQL>select * from v$logfile; -- redo log file Á¤º¸
SQL>spool off
±×¸®°í ÆĶó¹ÌÅÍ ÆÄÀÏÀÎ init<SID>.ora, (ifile À̶ó´Â ÆĶó¹ÌÅÍ·Î ¼³Á¤µÇ¾îÀÖ´Â)
config*.ora ¹é¾÷.
ÇÑ°¡Áö ´õ ÀÖ½À´Ï´Ù.
¹Ù·Î control file ÀÔ´Ï´Ù. ÀÌ°ÍÀº º¹±¸ ÇÒ ¶§ Áß¿äÇÑ ÆÄÀÏÀÔ´Ï´Ù.
control ÆÄÀÏÀº 2Áø ÆÄÀÏÀ̹ǷÎ, »ý¼ºÇØÁÖ´Â sql ½ºÅ©¸³Æ® ÆÄÀÏÀ» °¡Áö°í ÀÖÀ¸¸é ¿©
·¯ °¡Áö·Î Æí¸®ÇÕ´Ï´Ù.
SQL>alter database backup controlfile to trace ;
ÀÌ·¸°Ô ÇÏ°í init .ora ÆÄÀÏ¿¡(¶Ç´Â config .ora) ¼³Á¤µÈ user_dump_dest µð·ºÅ丮
·Î °¡¼
°¡Àå ÃÖ±ÙÀÇ *.trc ÆÄÀÏÀ» ¿¾îº¸¸é control ÆÄÀÏÀ» ¸¸µå´Â ½ºÅ©¸³Æ®°¡ Æ÷ÇԵǾî ÀÖ
½À´Ï´Ù.
ÀÌ°ÍÀ» ÆíÁýÇØ ³õÀ¸¸é ¹Ù·Î controlfileÀ» ¸¸µé¼ö ÀÖ½À´Ï´Ù.
control.sql »ùÇÃ
ORACLE_SID (= DB name) À» º¯°æÇßÀ» °æ¿ì
- UNIXÀÇ °æ¿ì
ORACLE_SID, DB_NAME ÆĶó¹ÌÅÍ°¡ µé¾î°¡´Â ¸ðµç ÆÄÀÏÀ» ã¾Æ¼ ¼öÁ¤ÇØ¾ß ÇÑ´Ù.
1. Ȩµð·ºÅ丮¿¡¼ ȯ°æº¯¼ö ¼³Á¤ÆÄÀÏÀÎ .profile(¶Ç´Â .cshrc)ÀÇ
ORACLE_SID=<new_SID> ºÎºÐÀ» ÆíÁýÇÏ°í
$. .profile (.cshrc ÀÇ °æ¿ì $ source .cshrc·Î ½ÇÇà)
·Î ½ÇÇà½ÃÄÑ ÁØ´Ù. ¾Æ´Ï¸é,
$export ORACLE_SID=ORATEST
¸¦ ¼öÇà½ÃÄÑ ÁØ´Ù.
2. /opt/var/oracle/oratab ÆÄÀÏÀ» ¿¾î SID:ORACLE_HOME path:Y/N¸¦ ¼öÁ¤
3. init*.ora ¶Ç´Â config*.ora ÆÄÀÏÀÇ db_nameÀ» ¼öÁ¤
4. ¾Æ·¡¿¡ ³ª¿Ã crdb*.sql ÆÄÀÏÀ» ¼öÁ¤
- NTÀÇ °æ¿ì
regedit ¸¦ ½ÇÇà½ÃÄÑ local_machine > software > oracle > home0 (oracle 8) ·Î
À̵¿ÇÏ¿© ORACLE_SID ¸¦ ¼öÁ¤ÇÕ´Ï´Ù. ±×¸®°í init*.ora ¶Ç´Â config*.ora ÆÄÀÏÀ»
¼öÁ¤.
2. database »ý¼º ½ºÅ©¸³Æ® crdb*.sql , crdb2*.sql ÆíÁý
oracle 7.3 ÀÌ»óÀÇ °æ¿ì
$ORACLE_HOME=/home1/oracle/app/oracle/product/7.3.3
À̶ó¸é crdb*.sql ÆÄÀϵéÀº
/home1/oracle/app/oracle/admin/ORA7/create
¿¡ À§Ä¡ÇÕ´Ï´Ù.
ÀÌ À§Ä¡·Î À̵¿ÇÏ¿© »õ·Î¿î À̸§À¸·Î copyÇÏ°í¼, ÇÊ¿äÇÑ ³»¿ëÀ» ¼öÁ¤ÇÕ´Ï´Ù.
À̶§ init *.ora µî ÆĶó¹ÌÅÍ ÆÄÀÏ°ú ¿¬µ¿µÇ´Â ºÎºÐ°ú °¢Á¾ µ¥ÀÌÅÍ ÆÄÀÏÀÇ
À§Ä¡¿Í Å©±â¸¦ ¼öÁ¤ÇÒ ¶§´Â ÁÖÀǸ¦ ±â¿ï¿©¾ß ÇÕ´Ï´Ù.
NT Àΰæ¿ì ÀÌ ½ºÅ©¸³Æ®°¡ ¾ø½À´Ï´Ù. sample ½ºÅ©¸³Æ® ÆÄÀÏÀ» ÂüÁ¶Çϼ¼¿ä.
crdboracle.sql sample.
crdb2oracle.sql sameple.
3. Create Database
$svrmgr <-------------------------- ¼¹ö¸Þ´ÏÁ®¸¦ ½ÇÇà (NTÀÇ °æ¿ì
svrmgrl.exe)
SVRMGR>connect internal <----- ·Î±×ÀÎ
SVRMGR>@crdboracle.sql
¹Ýµå½Ã ¿¡·¯¸¦ È®ÀÎÇÏ°í ´ÙÀ½À¸·Î ³Ñ¾î °¡¾ß ÇÕ´Ï´Ù.
SVRMGR>@crdb2oracle.sql
¶Ç È®ÀÎ ÇؾßÁÒ. ½Ã°£ÀÌ ´ë·« 1½Ã°£ Á¤µµ.°É¸³´Ï´Ù.
ÀÌ °úÁ¤ÀÌ ³¡³ª¸é µ¥ÀÌÅÍ ÆÄÀϵéÀº Á¦´ë·Î »ý¼ºµÇ¾ú´ÂÁö ²Ä²ÄÈ÷ È®ÀÎÇÏ°í ´ÙÀ½À¸·Î
³Ñ¾î°¡¾ß ÇÕ´Ï´Ù.
º¸Åë ¾Æ·¡°úÁ¤¿¡¼ ¿¡·¯°¡ »ý±â±â ¸¶·ÃÀÔ´Ï´Ù.
4. system table/view »ý¼º
¿ì¼± ORACLE_HOME/rdbms/admin µð·ºÅ丮·Î À̵¿ÇÏ¿©
catalog.sql, catproc.sql, catexp.sql ÀÇ 3°¡Áö ½ºÅ©¸³Æ® ÆÄÀÏÀÌ Á¸ÀçÇÏ´ÂÁö È®ÀÎ
ÇϽʽÿÀ.
SVRMGR>connect internal
SVRMGR>@$ORACLE_HOME/rdbms/admin /catalog
-- 20 ºÐ ¼Ò¿ä
SVRMGR>@$ORACLE_HOME/rdbms/admin /catproc
-- 1½Ã°£ ¼Ò¿ä
SVRMGR>@$ORACLE_HOME/rdbms/admin /catexp
-- 30ºÐ ¼Ò¿ä
¸¸ÀÏ À§ÀÇ ½ºÅ©¸³Æ®¸¦ µ¹¸®´Ù ¿¡·¯´Ù ½ÍÀ¸¸é µ¥ÀÌÅͺ£À̽º »ý¼ºÇÒ ¶§ ¹º°¡ À߸øµÈ
°ÍÀÔ´Ï´Ù.
È®ÀÎÇÏ°í ´Ù½Ã ½ÇÇà Çؾ߰ÚÁÒ..
5. µµ¿ò¸»°ú sample table / view »ý¼º
sqlplus¸¦ ½ÇÇàÇÏ°í system/manager ·Î login ÇÕ´Ï´Ù.
$ cd $ORACLE_HOME/sqlplus/admin/help
$ SYSTEM_PASS=system/manager;export SYSTEM_PASS
$ helpins
ÀÌ·¸°Ô Çؼ sqlplus ÀÇ µµ¿ò¸»À» ¼³Ä¡ÇÏ°í (NT ¿¡¼´Â ÀÌ·± °úÁ¤ÀÌ ÇÊ¿ä ¾ø½À´Ï
´Ù.)
´ÙÀ½¿¡ scott/tiger ÀÇ »ùÇà Å×À̺íÀ» ¼³Ä¡ÇÕ´Ï´Ù.
$ cd $ORACLE_HOME/sqlplus/admin
$ sqlplus system/manager
SQL> create user scott identified by tiger
default tablespace users temporary tablespace temp
quota unlimited on users
quota unlimited on temp;
SQL> grant connect,resource to scott;
SQL>@ $ORACLE_HOME/sqlplus/admin/pupbld.sql
SQL> connect scott/tiger;
SQL> @$ORACLE_HOME/sqlplus/demo /demobld.sql
À̷μ DBÀÇ À缳ġ ³¡~
6. ¹é¾÷ µ¥ÀÌÅÍ º¹¿ø
exp ·Î ¹é¾÷¹ÞÀº µ¥ÀÌÅ͸¦ º¹¿øÇÒ ¶§´Â imp ¸¦ »ç¿ëÇÏ¿© ¼±º°ÀûÀ¸·Î ¶Ç´Â full º¹¿ø
ÇÕ´Ï´Ù.
±×·¯³ª ÀÓÆ÷Æ® Çϱâ Àü¿¡ ÀÓÆ÷Æ®ÇÒ userid, tablespace °¡ Á¸ÀçÇÏ°í ÀÖ¾î¾ß ÇÕ´Ï
´Ù.
À̵éÀº ¹é¾÷¹ÞÀº ¸ÞŸµ¥ÀÌÅÍ Á¤º¸¸¦ ÀÌ¿ëÇؼ ´Ù½Ã »ì·Á ³õ½À´Ï´Ù.
SQL> create tablespace [name] datafile ¡®/data2/oracle/oradata ¡¦.¡¯ [Size
10M] [reuse]
Default storage( initial 1024 next 1024 ¡¦. );
ÀÏ´Ü Å×ÀÌºí ½ºÆäÀ̽º¸¦ ¸¸µé°í À¯Àú¸¦ »ý¼º.
SQL> create user [id] indentified by [passwd]
default tablespace [tablespace name] temporary tablespace [temp] ¡¦;
grant connect, resource to [id];
Export¹ÞÀº File¿¡¼ Index¸¦ Á¦¿ÜÇÑ ³ª¸ÓÁö¸¸ Import ÇÏ·Á¸é indexes=n ¿É¼ÇÀ» ÁÖ
°í,
$ imp system/manager file=fullbackup.dmp fromuser=scott touser=scott
indexes=n commit=y
Indexfile OptionÀ» ÀÌ¿ëÇÏ¿© Index Script¸¦ ¸¸µç´Ù.
$ imp system/managerfromuser=scott touser=scott file=scott.dmp
indexfile=index.sql
À§¿Í °°ÀÌ ¸í·ÉÀ» ½ÇÇàÇϸé index.sqlÀ̶ó´Â FileÀÌ ¸¸µé¾îÁö°í,
±× ÆÄÀÏÀ» ¿¾î¼ È®ÀÎÇØ º¸¸écreate table ¹®Àå°úcreate index¹®ÀåÀÌ ÀÖ°í
Create Table ¹®ÀåÀº REMÀ¸·Î ¸·Çô ÀÖ¾î¼ °á°úÀûÀ¸·Î Create Index¹®¸¸ ½ÇÇàÇÒ
¼ö ÀÖµµ·Ï µÇ¾î ÀÖ½À´Ï´Ù.
ÀÌ ÆÄÀÏ¿¡¼ Create Index¹®ÀÇ Tablespace¸¸ ¹Ù²Ù¾î¼ ´ÙÀ½°ú °°ÀÌ SQL*Plus¿¡
¼ ½ÇÇà.
$ sqlplus scott/tiger
SQL> @index
ÀÌ·± ½ÄÀ¸·Î Â÷·Ê·Î º¹±¸ ÇÏ¸é ±ú²ýÇÑ ¸¶À½À¸·Î º¹±¸ ³¡~
|