Oracle-修改数据文件

版权声明:Leo.All Rights Reserved. https://blog.csdn.net/qq_41113081/article/details/88873172

1.显示SGA系统全局区信息
show sga;
Total System Global Area 1258291200 bytes
Fixed Size                  1292156 bytes
Variable Size             318769284 bytes
Database Buffers          931135488 bytes
Redo Buffers                7094272 bytes
2.查询后台进程
         select * from V$bgprocess;
3.创建表空间 然后添加一个数据文件
   create tablespace mytbs01 
           datafile 'D:/df01.dbf' size 1m;
4.向表空间添加一个数据文件
  alter tablespace mytbs01
         add datafile 'D:/df02.dbf' size 1m;
5.查询表空间对应的数据文件
  select t1.name, t2.name 
      from v$tablespace t1, v$datafile t2  where t1.ts# = t2.ts#; 
6.修改数据文件大小 不需要下线
    alter database datafile 'D:/df01.dbf' resize 2m;
7.查询数据文件大小
    select name,bytes from V$datafile;
8.修改数据文件名字

一、首先让表空间处于OFFLINE
       alter tablespace mytbs01 offline;
二、手动修改物理文件的名称和位置
     把数据文件D:/df01.dbf  移动到了 C:/df001.dbf 并且名字修改为了df001.dbf
三、如果含有大量数据 可能需要recovery
四、修改逻辑上的数据文件名称
      alter tablespace mytbs01 rename datafile 'D:/df01.dbf' to 'C:/df001.dbf';
五、让表空间在线
     alter tablespace mytbs01 online;

9.1创建表到mytbs01表空间
create table stu(
    stuid int,
    stuname varchar2(10),
    stusex  varchar2(4)
)tablespace mytbs01;
9.2插入记录:
   insert into stu values(1,'小明','男');
    insert into stu values(2,'小红','女');
9.3插入列:
    alter table stu add(grade varchar2(10));
9.4修改记录:
   update stu set grade = '大二' where stuname='小明';
9.5修改列名:
   alter table stu rename column stuid to sno;
9.6修改列的定义:
   alter table stu modify sno int not null;
9.7删除列:
    alter table stu drop column sno;
9.8删除表:
   drop table stu;

 

猜你喜欢

转载自blog.csdn.net/qq_41113081/article/details/88873172