创建表空间:
- drop tablespace user_temp including contents and datafiles; - drop tablespace user_data including contents and datafiles; - drop tablespace user_index including contents and datafiles; - drop user C##AMAP cascade; - drop user amap cascade; - create temporary tablespace user_temp tempfile '/u01/app/oracle/oradata/orcl/amap/amap_temp.dbf' size 2G reuse autoextend on next 20m maxsize unlimited; - create tablespace user_data datafile '/u01/app/oracle/oradata/orcl/amap/amap.dbf' size 100M reuse autoextend on next 40M maxsize unlimited; - create tablespace user_index logging datafile '/u01/app/oracle/oradata/orcl/amap/amap_index.dbf' size 100m autoextend on next 32m maxsize 2048m extent management local;创建common用户:
create user c##amap identified by amap default tablespace user_data temporary tablespace user_temp ;创建local用户:
create user amap identified by amap default tablespace user_data temporary tablespace user_temp;用户授权:
- grant dba to amap; - grant connect to amap; - grant resource to amap; - grant unlimited tablespace to amap;导入命令
imp amap/amap@amap file=/opt/oracle/0430.dmp full=y查看当前实例:
select status,instance_name from v$instance;oracle 多个实例互相切换实例
windows中设置环境变量
set ORACLE_SID=alinux中设置环境变量
export ORACLE_SID=a//启动sqlplus
sqlplus / as sysdba
1.登录服务器,切换到oracle用户,或者以oracle用户登录
[admin@dataserver ~]$ su - oracle密码:
[oracle@dataserver ~]$2.打开监听服务
[oracle@localhost ~]$ lsnrctl start可以通过lsnrctl status命令查看Oracle监听器运行状况
[oracle@localhost ~]$ lsnrctl status3.以SYS用户身份登录Oracle
复制代码
[oracle@localhost ~]$ sqlplus /nologSQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 1 23:29:19 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdbaConnected to an idle instance.
切换用户:
CONN 用户名/密码 [AS SYSDBA],如果是sys用户一定要写上AS SYSDBA
4.通过startup命令启动实例
SQL> startupORACLE instance started.
Total System … … Database mounted. Database opened.
二、Linux下关闭Oracle
1.关闭数据库实例
SQL> shutdownDatabase closed. Database dismounted. ORACLE instance shut down.
SQL> quitDisconnected from Oracle Database 11g Enterprise Edition Release11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
2.关闭监听器
[oracle@localhost ~]$ lsnrctl stop