首页 > 代码库 > 任务型sql
任务型sql
1.创建表空间与用户,因为数据文件没有指定路径,所以需要修改数据文件路径,才有了下面的需求。
create tablespace wo datafile ‘wo.dbf‘ size 20m;
create user wo identified by "123abc" default tablespace wo;
grant connect,resource to wo;
针对非系统表空间,对sysaux,users表空间同样适用
select * from v$datafile;
select tablespace_name,file_name,online_status from dba_data_files where tablespace_name=‘WO‘;
alter tablespace WO offline;
host mv /u01/app/oracle/product/11.2/db_1/dbs/wo.dbf /u01/app/oracle/oradata/LCP1/datafile/
alter tablespace WO rename datafile ‘/u01/app/oracle/product/11.2/db_1/dbs/wo.dbf‘ to ‘/u01/app/oracle/oradata/LCP1/datafile/wo.dbf‘;
select tablespace_name,file_name,online_status from dba_data_files where tablespace_name=‘WO‘;
alter tablespace WO online;
针对系统表空间,对UNDOTBS1、TEMP表空间也适用。该方法需要数据库处于mount状态
shutdown immediate
startup mount
host mv /u01/app/oracle/product/11.2/db_1/dbs/system01.dbf /u01/app/oracle/oradata/LCP1/datafile/
alter tablespace WO rename datafile ‘/u01/app/oracle/product/11.2/db_1/dbs/system01.dbf‘ to ‘/u01/app/oracle/oradata/LCP1/datafile/system01.dbf‘;
alter database open;
select tablespace_name,file_name,online_status from dba_data_files where tablespace_name=‘SYSTEM‘;
任务型sql