1. 程式人生 > >Oracle 建立資料庫,使用者,表空間,資料匯入

Oracle 建立資料庫,使用者,表空間,資料匯入

以oa為例:
1 建立oa資料庫。字符集為utf-8。

2 prompt '建立LOGIN---oa'
create user oa IDENTIFIED BY oa;
GRANT ALTER ANY CLUSTER TO oa WITH ADMIN OPTION;
GRANT ALTER ANY INDEX TO oa WITH ADMIN OPTION;
GRANT ALTER ANY LIBRARY TO oa WITH ADMIN OPTION;
GRANT ALTER ANY PROCEDURE TO oa WITH ADMIN OPTION;
GRANT ALTER ANY ROLE TO oa WITH ADMIN OPTION;
GRANT ALTER ANY SEQUENCE TO oa WITH ADMIN OPTION;
GRANT ALTER ANY SNAPSHOT TO oa WITH ADMIN OPTION;
GRANT ALTER ANY TABLE TO oa WITH ADMIN OPTION;
GRANT ALTER ANY TRIGGER TO oa WITH ADMIN OPTION;
GRANT ALTER ANY TYPE TO oa WITH ADMIN OPTION;
GRANT ALTER DATABASE TO oa WITH ADMIN OPTION;
GRANT ALTER PROFILE TO oa WITH ADMIN OPTION;
GRANT ALTER RESOURCE COST TO oa WITH ADMIN OPTION;
GRANT ALTER ROLLBACK SEGMENT TO oa WITH ADMIN OPTION;
GRANT ALTER SESSION TO oa WITH ADMIN OPTION;
GRANT ALTER SYSTEM TO oa WITH ADMIN OPTION;
GRANT ALTER TABLESPACE TO oa WITH ADMIN OPTION;
GRANT ALTER USER TO oa WITH ADMIN OPTION;
GRANT ANALYZE ANY TO oa WITH ADMIN OPTION;
GRANT AUDIT ANY TO oa WITH ADMIN OPTION;
GRANT AUDIT SYSTEM TO oa WITH ADMIN OPTION;
GRANT BACKUP ANY TABLE TO oa WITH ADMIN OPTION;
GRANT BECOME USER TO oa WITH ADMIN OPTION;
GRANT COMMENT ANY TABLE TO oa WITH ADMIN OPTION;
GRANT CREATE ANY CLUSTER TO oa WITH ADMIN OPTION;
GRANT CREATE ANY DIRECTORY TO oa WITH ADMIN OPTION;
GRANT CREATE ANY INDEX TO oa WITH ADMIN OPTION;
GRANT CREATE ANY LIBRARY TO oa WITH ADMIN OPTION;
GRANT CREATE ANY PROCEDURE TO oa WITH ADMIN OPTION;
GRANT CREATE ANY SEQUENCE TO oa WITH ADMIN OPTION;
GRANT CREATE ANY SNAPSHOT TO oa WITH ADMIN OPTION;
GRANT CREATE ANY SYNONYM TO oa WITH ADMIN OPTION;
GRANT CREATE ANY TABLE TO oa WITH ADMIN OPTION;
GRANT CREATE ANY TRIGGER TO oa WITH ADMIN OPTION;
GRANT CREATE ANY TYPE TO oa WITH ADMIN OPTION;
GRANT CREATE ANY VIEW TO oa WITH ADMIN OPTION;
GRANT CREATE CLUSTER TO oa WITH ADMIN OPTION;
GRANT CREATE DATABASE LINK TO oa WITH ADMIN OPTION;
GRANT CREATE LIBRARY TO oa WITH ADMIN OPTION;
GRANT CREATE PROCEDURE TO oa WITH ADMIN OPTION;
GRANT CREATE PROFILE TO oa WITH ADMIN OPTION;
GRANT CREATE PUBLIC DATABASE LINK TO oa WITH ADMIN OPTION;
GRANT CREATE PUBLIC SYNONYM TO oa WITH ADMIN OPTION;
GRANT CREATE ROLE TO oa WITH ADMIN OPTION;
GRANT CREATE ROLLBACK SEGMENT TO oa WITH ADMIN OPTION;
GRANT CREATE SEQUENCE TO oa WITH ADMIN OPTION;
GRANT CREATE SESSION TO oa WITH ADMIN OPTION;
GRANT CREATE SNAPSHOT TO oa WITH ADMIN OPTION;
GRANT CREATE SYNONYM TO oa WITH ADMIN OPTION;
GRANT CREATE TABLE TO oa WITH ADMIN OPTION;
GRANT CREATE TABLESPACE TO oa WITH ADMIN OPTION;
GRANT CREATE TRIGGER TO oa WITH ADMIN OPTION;
GRANT CREATE TYPE TO oa WITH ADMIN OPTION;
GRANT CREATE USER TO oa WITH ADMIN OPTION;
GRANT CREATE VIEW TO oa WITH ADMIN OPTION;
GRANT DELETE ANY TABLE TO oa WITH ADMIN OPTION;
GRANT DROP ANY CLUSTER TO oa WITH ADMIN OPTION;
GRANT DROP ANY DIRECTORY TO oa WITH ADMIN OPTION;
GRANT DROP ANY INDEX TO oa WITH ADMIN OPTION;
GRANT DROP ANY LIBRARY TO oa WITH ADMIN OPTION;
GRANT DROP ANY PROCEDURE TO oa WITH ADMIN OPTION;
GRANT DROP ANY ROLE TO oa WITH ADMIN OPTION;
GRANT DROP ANY SEQUENCE TO oa WITH ADMIN OPTION;
GRANT DROP ANY SNAPSHOT TO oa WITH ADMIN OPTION;
GRANT DROP ANY SYNONYM TO oa WITH ADMIN OPTION;
GRANT DROP ANY TABLE TO oa WITH ADMIN OPTION;
GRANT DROP ANY TRIGGER TO oa WITH ADMIN OPTION;
GRANT DROP ANY TYPE TO oa WITH ADMIN OPTION;
GRANT DROP ANY VIEW TO oa WITH ADMIN OPTION;
GRANT DROP PROFILE TO oa WITH ADMIN OPTION;
GRANT DROP PUBLIC DATABASE LINK TO oa WITH ADMIN OPTION;
GRANT DROP PUBLIC SYNONYM TO oa WITH ADMIN OPTION;
GRANT DROP ROLLBACK SEGMENT TO oa WITH ADMIN OPTION;
GRANT DROP TABLESPACE TO oa WITH ADMIN OPTION;
GRANT DROP USER TO oa WITH ADMIN OPTION;
GRANT EXECUTE ANY LIBRARY TO oa WITH ADMIN OPTION;
GRANT EXECUTE ANY PROCEDURE TO oa WITH ADMIN OPTION;
GRANT EXECUTE ANY TYPE TO oa WITH ADMIN OPTION;
GRANT FORCE ANY TRANSACTION TO oa WITH ADMIN OPTION;
GRANT FORCE TRANSACTION TO oa WITH ADMIN OPTION;
GRANT GRANT ANY PRIVILEGE TO oa WITH ADMIN OPTION;
GRANT GRANT ANY ROLE TO oa WITH ADMIN OPTION;
GRANT INSERT ANY TABLE TO oa WITH ADMIN OPTION;
GRANT LOCK ANY TABLE TO oa WITH ADMIN OPTION;
GRANT MANAGE TABLESPACE TO oa WITH ADMIN OPTION;
GRANT RESTRICTED SESSION TO oa WITH ADMIN OPTION;
GRANT SELECT ANY SEQUENCE TO oa WITH ADMIN OPTION;
GRANT SELECT ANY TABLE TO oa WITH ADMIN OPTION;
GRANT UNLIMITED TABLESPACE TO oa WITH ADMIN OPTION;
GRANT UPDATE ANY TABLE TO oa WITH ADMIN OPTION;
GRANT "AQ_ADMINISTRATOR_ROLE" TO oa WITH ADMIN OPTION;
GRANT "AQ_USER_ROLE" TO oa WITH ADMIN OPTION;
GRANT "CONNECT" TO oa WITH ADMIN OPTION;
GRANT "DBA" TO oa WITH ADMIN OPTION;
GRANT "DELETE_CATALOG_ROLE" TO oa WITH ADMIN OPTION;
GRANT "EXECUTE_CATALOG_ROLE" TO oa WITH ADMIN OPTION;
GRANT "EXP_FULL_DATABASE" TO oa WITH ADMIN OPTION;
GRANT "HS_ADMIN_ROLE" TO oa WITH ADMIN OPTION;
GRANT "IMP_FULL_DATABASE" TO oa WITH ADMIN OPTION;
GRANT "RECOVERY_CATALOG_OWNER" TO oa WITH ADMIN OPTION;
GRANT "RESOURCE" TO oa WITH ADMIN OPTION;
GRANT "SELECT_CATALOG_ROLE" TO oa WITH ADMIN OPTION;


3set verify off
define tb_path='D:\app\Administrator\oradata\oa'
prompt '建立表空間開始...'
prompt '建立oa臨時表空間---oa_tmp'
CREATE TEMPORARY TABLESPACE "OA_TMP" TEMPFILE 
'&tb_path\OA_TMP.ora' SIZE 5M AUTOEXTEND 
ON NEXT  64K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL 
UNIFORM SIZE 1M;
alter database default temporary tablespace oaGBK_TMP;
prompt '建立oa預設資料表空間---oa_dat'
CREATE TABLESPACE "OA_DAT" 
LOGGING 
DATAFILE '&tb_path\OA_DAT.ora' SIZE 5M 
AUTOEXTEND 
ON NEXT  64K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL 
SEGMENT SPACE MANAGEMENT  AUTO;
prompt '建立oa索引表空間---oa_idx'
CREATE TABLESPACE "OA_IDX" 
LOGGING 
DATAFILE '&tb_path\OA_IDX.ora' SIZE 5M 
AUTOEXTEND 
ON NEXT  64K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL 
SEGMENT SPACE MANAGEMENT  AUTO;
prompt '建立oa日誌表空間---oa_log'
CREATE TABLESPACE "OA_LOG" 
LOGGING 
DATAFILE '&tb_path\OA_LOG.ora' SIZE 5M 
AUTOEXTEND 
ON NEXT  64K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL 
SEGMENT SPACE MANAGEMENT  AUTO;
prompt '建立表空間完畢!'
set feedback off


4      imp 登入名/登入密碼@SID file=檔案完整路徑 full=y