create user cmdb_1023> 3.--给权限
grant connect,resource,dba to cmdb_db;
4.--导入数据(在命令窗口执行)
imp cmdb/admin file=/home/cmdb_henan.dmp fromuser=cmdb_L touser=cmdb;
5.--导出数据
exp cmdn/admin owner=cmdb file=/u01/app/oracle/cmdb_heinan.dmp;
6.--删除表空间
drop tablespace CMDB_db including contents and datafiles;
7.--查看表空间与文件路径
select tablespace_name,file_id,bytes/1024/1024,file_name from dba_data_files order by file_id;
8.--删除用户并删除用户下所有数据
drop user cmdb_perftests cascade;
删除过程中可能遇到报错:cannot drop a user that is currently connected 提示有人连接用户,不能够删除!此时请使用以下语句,删除连接再删用户。
select sid,serial# from v$session where username='CMDB_HLJ'; 查询CMDB_HLJ这个数据库正在连接的SID,SERIAL#
alter system kill session '54,5'; 杀死连接'SID,SERIAL'
alter system kill session '98,select * from sys.dba_tablespaces;23'; 杀死连接'SID,SERIAL'
alter system kill session '137,3'; 杀死连接'SID,SERIAL'
DROP USER CMDB_HLJ cascade; 删除用户
9.--查看表空间名称
select * from sys.dba_tablespaces;
10.--导出数据库,空表未导出问题(第一次导出时执行)
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0;
复制此语句的执行结果,删除所有不是alter table 开头的语句,再次执行复制的语句。
《注:连接用户为当前要执行的用户》 Orcale数据库与监听启动与停止操作
(1) 以oracle身份登录数据库,命令:su – oracle
(2) 进入Sqlplus控制台,命令:sqlplus /nolog