创建表空间:
- 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=a
linux中设置环境变量
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 status
3.以SYS用户身份登录Oracle
复制代码
[oracle@localhost ~]$ sqlplus /nolog
SQL*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 sysdba
Connected to an idle instance.
切换用户:
CONN 用户名/密码 [AS SYSDBA],如果是sys用户一定要写上AS SYSDBA
4.通过startup命令启动实例
SQL> startup
ORACLE instance started.
Total System … … Database mounted. Database opened.
二、Linux下关闭Oracle
1.关闭数据库实例
SQL> shutdown
Database closed. Database dismounted. ORACLE instance shut down.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release
11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
2.关闭监听器
[oracle@localhost ~]$ lsnrctl stop