oracle管理常用命令整理(一)

表空间

创建表空间

create tablespace test

datafile 'C:oracleproduct10.2.0oradataora10gtest01.dbf' size 100m

--extent management local --空间管理(默认local)

--autoallocate 100m --区段分配(默认auto)

--uniform size 5m --同一区段分配(默认1M)

--segment space management auto --段空间管理,只能用于本地管理表空间(默认auto)

--blocksize 8k --块大小(默认为DB_BLOCK_SIZE的值)

--查看表空间管理信息

select initial_extent,next_extent,extent_management,allocation_type,segment_space_management

from dba_tablespaces

where tablespace_name='TEST';

[@more@]

增加表空间大小

--增加新的数据文件

alter tablespace test add datafile 'C:oracleproduct10.2.0oradataora10gtest02.dbf' size 100m;

--扩展已有数据文件

alter database datafile 'C:oracleproduct10.2.0oradataora10gtest01.dbf' resize 500m;

--表空间自动扩展(只有在创建表空间或增加新数据文件时才能加autoextend)

alter tablespace test

add datafile 'C:oracleproduct10.2.0oradataora10gtest02.dbf' size 100m

autoextend on

next 10M

maxsize unlimited;

删除表空间

--删除包含对象的表空间

drop tablespcae test including contents;

--同时删除操作系统数据文件

drop tablespace test including contents and datafiles;

--同时删除引用的完整性约束

drop tablespace test cascade contraints;

重命名表空间和数据文件

--重命名表空间(10g新特性)

alter tablespace test01 rename to test02;

--重命名数据文件

1.alter tablespace test01 offilne normal;

2.操作系统命令修改数据文件名或移动到另外的位置

3.alter tablespace test01 rename datafile 'C:oracleproduct10.2.0oradataora10gtest01.dbf' to

'C:oracleproduct10.2.0oradataora10gtest02.dbf';

或 alter database rename file 'C:oracleproduct10.2.0oradataora10gtest01.dbf' to

'C:oracleproduct10.2.0oradataora10gtest02.dbf'; --mount状态(针对无法脱机的表空间)

修改表空间为只读

alter tablespace test read only;

alter tablespace test read write;

修改表空间为脱机

alter tablespace test offline normal;

alter tablespace test online;

释放未用的extent

--手动释放

alter table test deallocate unused;

--删除中同时释放extent

truncate table test drop storage;

字典管理表空间转换为本地管理表空间

--移植所以对象到本地管理表空间

alter table test01 move tablespace test02;

alter index test01_pk_idx rebuild tablespace test02;

--使用DBMS_SPACE_ADMIN转换(可联机转换,system表空间必须最后转换)

execute dbms_space_admin.tablespace_migrate_local('TEST01');

创建临时表空间

Create temporary tablespace temp01

Tempfile 'C:oracleproduct10.2.0oradataora10gtemp01.dbf' size 500m

Autoextend on;

--临时表空间信息

V$sort_segment

V$tempseg_usage

修改默认的临时表空间

Alter tablespace default temporary tablespace temp_test;

创建临时表空间组(10g新特性)

--创建临时表空间时创建临时表空间组

Create temporary tablespace temp01

Tempfile 'C:oracleproduct10.2.0oradataora10gtemp01.dbf' size 100m

Tablespace group tmpgrp1; --默认不属于任何组

--修改时创建临时表空间组

Alter tablespace temp01 tablespace group tmpgrp1;

--临时表空间组信息

Dba_tablespace_groups;

将临时表空间组设为数据库默认的临时表空间

Alter database default temporary tablespace tmpgrp1;

设定默认的永久表空间

1.建库时使用default tablespace子句

2.Alter database default tablespace test;

--查看当前的默认永久表空间

Select property_name,property_value from database_properties;

创建大文件表空间(一对一)--建库时设置默认表空间为BFT

Create database

Set default bigfile tablespace

……

--创建表空间时指定BFT

Create bigfile tablespace test

Datafile 'C:oracleproduct10.2.0oradataora10gtest01.dbf' size 100G;

--改变默认表空间类型

Atler tablespace set default bigfile tablespace;

更改大文件表空间

Alter tablespace bigtbs resize 120G;

Alter tablespace bigtbs autoextend on next 20G; --小文件表空间不支持该操作

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10176825/viewspace-1017892/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10176825/viewspace-1017892/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值