1. 程式人生 > >CentOS7.5安裝oracle例項

CentOS7.5安裝oracle例項

關閉防火牆

[[email protected] /]# systemctl stop firewalled service
[[email protected] /]# systemctl disable firewalled service

關閉selinux

[[email protected] /]# yum install vim
[[email protected] /]# vim /etc/selinux/config
[[email protected] /]# selinux=encourceing改為disabled

建立執行oracle資料庫的使用者組和系統使用者

[[email protected] /]# groupadd oinstall //建立使用者組oinstall
[[email protected] /]# groupadd dba //建立使用者組dba
[[email protected] /]# useradd -g oinstall -g dba -m oracle //建立使用者oracle,並加入到oinstall和dba使用者組
[[email protected] /]# passwd oracle //設定使用者oracle的登入密碼
[root[email protected]
/]# id oracle //檢視新建的使用者oracle

建立資料庫安裝目錄並授權

[[email protected] /]# mkdir -p /app/oracle //安裝目錄
[[email protected] /]# mkdir -p /app/oraInventory //配置檔案目錄
[[email protected] /]# mkdir -p /app/database // 解壓目錄
[[email protected] /]# chown -R oracle:oinstall /app/oracle
[[email protected] /]# chown -R oracle:oinstall /app/oraInventory
[[email protected] /]# chown -R oracle:oinstall /app/database

修改OS系統標識

# 注:CentOS系統預設不支援oracle資料庫安裝,需要修改系統標識為redhat-7
[[email protected] /]# cat /proc/version //檢視Linux系統版本
[[email protected] /]# cat /etc/redhat-realease //檢視CentOS系統版本
CentOS Linux release 7.2.1511(Core)
[[email protected] /]# vi /etc/redhat-realease  //CentOS7改為redhat7
redhat-7

修改核心引數

[[email protected] /]# vi /etc/sysctl.conf
#System default……
#To override……
#
#For more……

#新增下方配置引數
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.rp_filter = 1
fs.file-max = 6815744 #設定最大開啟檔案數
fs.aio-max-nr = 1048576
kernel.shmall = 2097152 #共享記憶體的總量,8G記憶體設定:2097152*4k/1024/1024
kernel.shmmax = 2147483648 #最大共享記憶體的段大小
kernel.shmmni = 4096 #整個系統共享記憶體端的最大數
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4埠範圍
net.core.rmem_default = 262144
net.core.rmem_max= 4194304
net.core.wmem_default= 262144
net.core.wmem_max= 1048576

使配置引數生效:

[[email protected] /]# sysctl -p

對oracle使用者設定限制,提高軟體執行效能

[[email protected] /]# vi /etc/security/limits.conf

#@student - maxlogins 4
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

# End of file

配置使用者的環境變數

export ORACLE_BASE=/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:/user/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LANG=C
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
#AMERICAN_AMERICA.ZHS16GBK #設定Oracle客戶端字符集,必須 與Oracle安裝時設定的字符集保持一致,如:ZHS16GBK,否則出現數據匯入匯出 中文亂碼問題
#註釋掉原來的#PATH和#export PATH
#使上述配置立即生效:
[[email protected] /]# source /home/oracle/.bash_profile

增加主機名

#注:若不執行此步,則配置監聽時會出錯,系統無法識別監聽。
[[email protected] /]#  $hostname
[[email protected] /]# vi /etc/sysconfig/network
# Created by anaconda
[[email protected] /]# hostname=lgswork //增加hostname
[[email protected] /]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 lgswork
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[[email protected] /]# hostname lgswork  //執行

安裝oracle資料庫所需的軟體包

[[email protected] /]# yum install gcc* gcc-* gcc-c++-* glibc-devle-* glibc-headers-* compat-libstdc* libstdc* elfutils-libelf-devel* libaio-devel* sysstat* unixODBC-* pdksh-* make ksh binutils -y

解壓縮

[[email protected] /]#yum install unzip
# 將3個壓縮檔案放到/app下
[[email protected] /]# su - oracle
[[email protected]]$ cd /app
[[email protected]]$ unzip oracle_11.2.0.4_Linux-64_1of7.zip -d /app/database
[[email protected]]$ unzip oracle_11.2.0.4_Linux-64_2of7.zip -d /app/database

安裝

[[email protected]]$ cd /app/database
[[email protected]]$ ./runInstaller

Prerequisite Checks

#1 swap 空間不足解決:  (要求2.67 實際2)
[[email protected] /]# free -m  //檢視當前虛擬記憶體
[[email protected] /]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000 //將當前swap 空間由2048M增加到3048M新增一個2014的swap檔案
[[email protected] /]# swapon /home/swap //增加並啟用虛擬內容
[[email protected] /]#  free -m  //再次檢視

#2 package檢測失敗
#因為現有的包的版本比檢測要高,最後忽略即可。也可下載相應的package後:
[[email protected] /]# rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm(需cd到包所在目錄)
#3 安裝過程是一個漫長的過程,中間有幾次卡住,沒有出現任何畫面,螢幕中間有 條小線,嘗試多次,發現游標在該線上,右鍵點選Closed,也可esc或enter。

Install Product

#1 execute root scripts(根指令碼執行)-failed
#切換到root使用者:
[[email protected]]$ su - root
[[email protected] /]# cd /app/oraInventory
[[email protected] /]# ./orainstRoot.sh
[[email protected] /]# cd /app/oracle/product/11.2.0/db_1
[[email protected] /]# ./root.sh
#執行完這個指令碼後在點選try便可執行成功

監聽

[[email protected] ~]$ netca //配置監聽
[[email protected] ~]$ lsnrctl status //檢視監聽狀態
[[email protected] ~]$ dbca //建立資料庫例項orcl

Error in invoking target ‘agent nmhs’ of makefile

Error in invoking target 'agent nmhs' of makefile
安裝Oracle11g報錯:
Error in invoking target 'agent nmhs' of makefile  
解決方法:
cd $ORACLE_HOME/sysman/lib
vi ins_emagent.mk 
修改此處如下:
#===========================
#  emdctl
#===========================
$(SYSMANBIN)emdctl:
  $(MK_EMAGENT_NMECTL)-lnnz11
*******VICTORY LOVES PREPARATION*******

DISPLAY not set.

Set DISPLAY environment variable, then re-run.

以root使用者登入
在執行xhost +命令(使得所有客戶都可以訪問)
若返回資訊為: 
access control disabled,clients can connect from any host   
表示xhost +可執行直接切換至oracle使用者執行安裝oracle
如果xhost +不能執行,
第一步:用root登陸linux,啟動vnc服務;
第二步:根據vnc起來的埠,設定export DISPLAY=:1(1表示vnc在第一個tty上啟動的),vnc的啟動資訊見下文的linux操作日誌;
第三步:xhost + ip (ip為主機ip地址)

2、以oracle使用者登入
那麼在該oracle使用者下執行一下export DISPLAY=:1.0
然後再執行xdpyinfo命令,如果能出現資訊說明你已經成功了
這樣估計就可以解決linux下安裝oracle出現的xhost問題

3、執行命令 ./runInstaller 安裝oracle
linux下的操作日誌如下:
[[email protected] ~]# vncserver
New 'localhost:1 (root)' desktop is localhost:1
Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/localhost:1.log
[[email protected] ~]# export DISPLAY=localhost:1
[[email protected] ~]# xhost +
access control disabled, clients can connect from any host

重建EM:emca -repos recreate

重建EM:emca -repos recreate

手工重新配置EM
[email protected]:/oracle/app/oracle/product/11.2.0/db_1/oc4j/j2ee/OC4J_DBConsole>  emca -config dbcontrol db

STARTED EMCA at Jan 17, 2014 3:13:05 PM
EM Configuration Assistant, Version 11.2.0.0.2 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Enter the following information:
Database SID: orcl
Listener port number: 1521
Listener ORACLE_HOME [ /oracle/app/grid_home ]: 
Password for SYS user:  
Password for DBSNMP user:  
Password for SYSMAN user:  
Email address for notifications (optional): [email protected]
Outgoing Mail (SMTP) server for notifications (optional): 
ASM ORACLE_HOME [ /oracle/app/grid_home ]: 
ASM SID [ +ASM ]: 
ASM port [ 1521 ]: 
ASM username [ ASMSNMP ]: 
ASM user password:  
-----------------------------------------------------------------

You have specified the following settings

Database ORACLE_HOME ................ /oracle/app/oracle/product/11.2.0/db_1

Local hostname ................ linux.site
Listener ORACLE_HOME ................ /oracle/app/grid_home
Listener port number ................ 1521
Database SID ................ orcl
Email address for notifications ............... [email protected]
Outgoing Mail (SMTP) server for notifications ............... 
ASM ORACLE_HOME ................ /oracle/app/grid_home
ASM SID ................ +ASM
ASM port ................ 1521
ASM user role ................ SYSDBA
ASM username ................ ASMSNMP

-----------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: Y
Nov 22, 2018 3:43:46 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /app/oracle/cfgtoollogs/emca/orcl/emca_2018_11_22_03_43_04.log.
Nov 22, 2018 3:43:47 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...
Nov 22, 2018 3:44:17 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Nov 22, 2018 3:44:19 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Nov 22, 2018 3:44:24 AM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Nov 22, 2018 3:44:24 AM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Nov 22, 2018 3:44:51 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Nov 22, 2018 3:44:52 AM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is 
   ##  https://localhost:1158/em 
<<<<<<<<<<<
Nov 22, 2018 3:44:53 AM oracle.sysman.emcp.EMDBPostConfig invoke
WARNING: 
************************  WARNING  ************************

Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted.  The encryption key has been placed in the file: /app/oracle/product/11.2.0/db_1/localhost_orcl/sysman/config/emkey.ora. Ensure this file is backed up as the encrypted data will become unusable if this file is lost. 

***********************************************************
Enterprise Manager configuration completed successfully
[[email protected] /]# /oracle/app/oraInventory/orainstRoot.sh
Changing permissions of /oracle/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /oracle/app/oraInventory to oinstall.
The execution of the script is complete.
[[email protected] /]# /oracle/app/oracle/product/11.2.0/root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /oracle/app/oracle/product/11.2.0
Enter the full pathname of the local bin directory: [/usr/local/bin]:
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...
   
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product‐specific root actions will be performed.
Finished product‐specific root actions.
[[email protected] oracle]$ cd /oracle
[[email protected] oracle]$ ls
app  lost+found
[[email protected] oracle]$ mkdir oradata
[[email protected] oracle]$ pwd
/oracle

安裝完成後檢查是否已安裝成功

[[email protected] database]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sat Nov 25 14:48:59 2017
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 ‐ 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing
options
SQL> select status,instance_name from v$instance;
STATUS       INSTANCE_NAME
‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
OPEN         db01
SQL> select name,open_mode from v$database;
NAME      OPEN_MODE
‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
DB01      READ WRITE

[[email protected] database]$ emctl status dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
https://db01:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is running.
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
Logs are generated in directory
/oracle/app/oracle/product/11.2.0/db01_db01/sysman/log
[[email protected] database]$
檢視是否有報錯資訊
SQL> show parameter dump
NAME                                 TYPE        VALUE
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐ ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
‐‐‐‐‐‐‐‐‐
background_core_dump                 string      partial
background_dump_dest                 string     
/oracle/app/oracle/diag/rdbms/
                                                 db01/db01/trace
core_dump_dest                       string     
/oracle/app/oracle/diag/rdbms/
                                                 db01/db01/cdump
max_dump_file_size                   string      unlimited
shadow_core_dump                     string      partial
user_dump_dest                       string     
/oracle/app/oracle/diag/rdbms/
                                                 db01/db01/trace
SQL> exit   
Disconnected from Oracle Database 11g Enterprise Edition Release
11.2.0.4.0 ‐ 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing
options
[[email protected] oracle]$ cd
/oracle/app/oracle/diag/rdbms/db01/db01/trace/
[[email protected] trace]$ ls
[[email protected] trace]$ cat alert_db01.log |grep ORA‐
ORA‐1109 signalled during: ALTER DATABASE CLOSE NORMAL...
ORA‐00313: open failed for members of log group 1 of thread 1
ORA‐00312: online log 1 thread 1: '/oracle/oradata/db01/redo01.log'
ORA‐27037: unable to obtain file status
ORA‐00313: open failed for members of log group 1 of thread 1
ORA‐00312: online log 1 thread 1: '/oracle/oradata/db01/redo01.log'
ORA‐27037: unable to obtain file status
Clearing online redo logfile 5 complete
Online log /oracle/oradata/db01/redo01.log: Thread 1 Group 1 was
previously cleared
Online log /oracle/oradata/db01/redo02.log: Thread 1 Group 2 was
previously cleared
Online log /oracle/oradata/db01/redo03.log: Thread 1 Group 3 was
previously cleared
Online log /oracle/oradata/db01/redo04.log: Thread 1 Group 4 was
previously cleared
Online log /oracle/oradata/db01/redo05.log: Thread 1 Group 5 was
previously cleared
可以發現有報錯資訊,但資料庫已經自動例項恢復了。

ORACLE is not in the sudoers file

解決辦法:只要修改一下/etc/sudoers檔案就行了。
1.進入超級使用者模式。也就是輸入"su-",系統會讓你輸入超級使用者密碼,輸入密碼後就進入了超級使用者模式。(注:您也可以直接用root登入);
2.新增檔案的寫許可權,因為sudoers這個檔案只允許讀,不允許寫入。輸入命令"chmod u+w /etc/sudoers";
3.編輯/etc/sudoers檔案。輸入命令"vi/etc/sudoers",輸入"i"進入編輯模式,找到這一行:"root ALL=(ALL) ALL",在這行下面新增"xxxALL=(ALL) ALL"(這裡的xxx是你的使用者名稱),然後按Esc鍵,輸入":wq",儲存退出;
4.撤銷檔案的寫許可權,還原檔案的讀寫狀態。輸入命令"chmod u-w /etc/sudoers"(一定要記得撤銷,否則可能引起其他問題)

ping unknown host

[[email protected] ~]# ping www.baidu.com
提示 ping: unknown host
這是因為DNS伺服器沒有配置好,如果網路沒有問題,可以按下面的步驟進行檢查:
1) vi /etc/resolv.conf
新增
nameserver 192.168.59.2       本機的閘道器地址(路由器的地址)
search localdomain    # search 引數指定域名查詢順序
2)設定閘道器
vi /etc/sysconf/network-scripts/ifcfg-eth0
新增
GATEWAY=192.168.59.2
或者
使用命令設定
route add default gw 192.168.59.2
然後重新啟動網路服務:
service network restart
3)確保可用DNS解析
[[email protected] Desktop]# grep hosts /etc/nsswitch.conf
輸出
hosts:      files dns
該檔案/etc/nsswith.conf是SUN公司開發的一種擴充套件name server switch。用於設定檔案讀取的順序,如是先讀取/etc/hosts檔案,還是先查詢DNS伺服器。
hosts:      files dns  指定先查詢/etc/hosts檔案,如果失敗,則到DNS伺服器查詢與域名相對應的主機資訊。
4)測試DNS
ping www.baidu.com

使用PL/SQL連線Oracle時報錯ORA-12541: TNS: 無監聽程式

出現這個報錯,思路:
思路一:IP地址(伺服器IP地址)能否ping通
開啟DOS視窗(cmd),輸入:ping 10.10.1.11
能ping通;
思路二:IP地址(伺服器IP地址)及埠是否可以用
開啟DOS視窗(cmd),輸入:telnet 10.10.1.11 1521
可能會報錯:'telnet' 不是內部或外部命令,也不是可執行的程式或批處理檔案。
解決辦法:參考:telnet不是內部或外部命令,也不是可執行的程式
開啟“控制面板”找到“程式”
點選“啟用或關閉Windows功能”
勾選“Telnet客戶端”,點選確定
重新開啟dos命令視窗,輸入“telnet ip地址 埠號”,測試成功!

TNS-12541: TNS:no listener , TNS-12542: TNS:address already in use

檢視資料庫監聽狀態不對
$ lsnrctl status

LSNRCTL for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Production on 05-NOV-2012 08:54:08

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
  IBM/AIX RISC System/6000 Error: 79: Connection refused
然後手動啟動資料庫報如下錯誤:
$ lsnrctl start

LSNRCTL for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Production on 05-NOV-2012 08:54:12

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Starting /oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Production
System parameter file is /oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /oracle/product/10.2.0/db_1/network/log/listener.log
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))
TNS-12542: TNS:address already in use
 TNS-12560: TNS:protocol adapter error
  TNS-00512: Address already in use
  IBM/AIX RISC System/6000 Error: 67: Address already in use

Listener failed to start. See the error message(s) above...

/oracle/product/10.2.0/db_1/network/trace/listener.trc

明明監聽沒啟動起,卻說已經在運行了,後來終於找到原因,網上看到別人也碰到這個問題,說是HOSTS檔案設定有問題,檢視本機主機名和hosts檔案,果然有問題,兩個IP地址指向了同一個主機名,將一臺主機刪除後,再啟動監聽,一切OK。

用root使用者進行修改:
# cat /etc/hosts

# Internet Address      Hostname        # Comments
# 192.9.200.1          net0sample      # ethernet name/address
# 128.100.0.1          token0sample    # token ring name/address
# 10.2.0.2              x25sample      # x.25 name/address
# 2000:1:1:1:209:6bff:feee:2b7f        ipv6sample      # ipv6 name/address
127.0.0.1              loopback localhost      # loopback (lo0) name/address
192.168.101.189  test
192.168.101.190  test

再次啟動監聽:
$ lsnrctl start

LSNRCTL for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Production on 05-NOV-2012 08:58:47
Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Starting /oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Production
System parameter file is /oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                    LISTENER
Version                  TNSLSNR for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Production
Start Date                05-NOV-2012 08:58:49
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level              off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File  /oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File        /oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
總結:/etc/hosts檔案設定很重要,這裡設定不正確,很多地方都要出錯,特別是RAC,會報很多奇怪的錯誤,配置的時候要多注意。

oracle 11g 指令碼建立表空間和使用者

/*分為四步 */
/*第1步:建立臨時表空間 */
create temporary tablespace test_temp 
tempfile 'D:\app\Administrator\product\11.2.0\dbhome_1\database\test_temp.dbf' 
size 10m 
autoextend on 
next 10m maxsize 20480m 
extent management local; 
/*第2步:建立資料表空間 */
create tablespace test 
logging 
datafile 'D:\app\Administrator\product\11.2.0\dbhome_1\database\test.dbf' 
size 10m 
autoextend on 
next 10m maxsize 20480m 
extent management local; 
/*第3步:建立使用者並指定表空間 */
create user test identified by test1234 
default tablespace testi
temporary tablespace test_temp; 
/*第4步:給使用者授予許可權 */
grant connect,resource,dba to test;

--查詢當前表空間
select tablespace_name,file_id,file_name,bytes
from dba_data_files
order by file_id

where tablespace_name='test'
--刪除表空間
drop tablespace em;
--刪除使用者
drop user e [CASCADE];