Oracle 自学

本文深入探讨了Ubuntu 12.04 Server环境下使用Oracle 11g SQL Developer进行数据库管理的基础概念,包括表空间、段、区段、数据块等关键元素的理解,以及如何通过SQL查询来获取和分析数据库信息,如表、索引、分区等对象的状态和大小。文章还提供了实例展示了如何创建表空间、管理内存消耗和空间利用,特别关注了表分区和索引在处理大量数据时的效率对比。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[size=large][b]自己看的[/b][/size]

ubuntu12.04 server version
oracle11g
sqldeveloper

一些基础概念
tablespace 表空间 = 若干段组成
segment 段 = 若干区段组成
extent 区段 = 若干相邻的数据块
block 数据块

如何了解table,index,table partition大小
[img]http://dl.iteye.com/upload/attachment/0084/3848/5251f7cb-00fe-3415-aad2-76353fe554e1.png[/img]


结合数据库的常用表,了解数据库的一些信息
-- check all user;
select * from all_users;

-- current oracle database name
select ora_database_name from dual

-- current user object
select owner, object_type, status, count(*) count# from all_objects where owner = 'SCOTT' group by owner, object_type, status;
SELECT object_type FROM user_objects GROUP BY object_type;

-- all object own by current user
select * from user_objects where object_type = 'TABLE PARTITION';
select * from user_objects where object_type = 'SEQUENCE';
select * from user_objects where object_type = 'TRIGGER';
select * from user_objects where object_type = 'INDEX';
select * from user_objects where object_type = 'TABLE';

select * from user_tablespaces;
select * from user_sequences;
select * from USER_TABLES;
select * from USER_TRIGGERS;
select * from user_indexes;
select * from user_procedures;

-- good resource, segment type (table, table partition, index) check capacity of segement type
-- check capacity, come here
select * from user_segments;

-- consume disk space
select tablespace_name, initial_extent/1024/1024, next_extent/1024/1024, min_extents/1024/1024, max_extents/1024/1024, max_size/1024/1024 from user_tablespaces;
select segment_type, segment_name, bytes/1024/1024 capacity from user_segments where segment_type = 'TABLE';
select segment_type, segment_name, bytes/1024/1024 capacity from user_segments where segment_type = 'TABLE PARTITION';
select segment_type, segment_name, bytes/1024/1024 capacity from user_segments where segment_type = 'INDEX';


结合oem,了解当前数据库主要空间消耗情况

-- start oem (Oracle Enterprise Manager) in ubuntu
0) $ORACLE_HOME/oc4j/j2ee/oc4j_applications/applications/em/em/WEB-INF/uix-config.xml inaccessible->accessible,
1) emctl start dbconsole
2) https://ubuntu:1158/em/
3) emctl start dbconsole


手动创建表空间 JRD_GPS, TAXI_Temp
[img]http://dl.iteye.com/upload/attachment/0084/3914/6d89b2f1-41bb-31df-8f2d-b5af54cc651c.png[/img]

Table Partition内存消耗, [b](三千万条数据,2G多)[/b]
[img]http://dl.iteye.com/upload/attachment/0084/3910/c46f04db-16b3-31c5-baee-a4ab437de67e.png[/img]

Table Partition索引消耗 [b](三千万条数据,主键索引4G,吓,其他键1G不到)[/b]
[img]http://dl.iteye.com/upload/attachment/0084/3912/c5673d1f-dd51-3872-87ff-ac765546cead.png[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值