跳至主要内容

Oracle学习笔记20071224

移动data files
tablespace类
首先需要将tablespace设置为offline,然后目标data files必须存在
然后使用:
SQL>ALTER TABLESPACE userdata RENAME DATAFILE '/u01/oradata/userdata01.dbf'
TO '/u01/oradata/userdata01.dbf';

database类
database必须mount,目标datafile必须存在
SQL>ALTER DATABASE RENAME FILE '/u01/oradata/system01.dbf'TO
'/u03/oradata/system01.dbf';

修改Tablespace的建立在Oracle的管理文件
SQL>ALTER SYSTEM SET db_create_file_dest = '/u01/oradata/db01';


关于表
从逻辑结构来说分为oracle,extent,segment,tablespace,database
物理测试datafile,OS blocks

segments的种类分为table,cluster,index,partition,index-organized table,index partition,undo segment,temporary segment,lob segment,nested table,bootstrap segment

DATABASE BLOCK最小的单位的I/O,由一个或多个OS blocks组成,由tablespace creation建立,db_block_size是默认大小
管理DATA BLOCK有两种方法,一种自动,一种手动。
自动语法:
SQL>CREATE TABLESPACE data02 DATAFILE '/u01oradata/data02.dbf' SIZE 5M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 64K SEGMENT SPACE MANAGEMENT AUTO;

手动语法需要用到PCTFREE,PCTUSED,FREELIST这几个参数
例如,假设整个blockspace为100,那么set pctfree = 20,pctused =40,如果PCTUSED>80的话那么将不能插入,如果大于40的话则可以在插入。

Used extents对应的是dba_extents视图,Fredd extents对应的是dba_free_space,Segments对应的是dba_segments,Data Files对应的是dba_data_files,tablespace对应的是dba_tablespaces,

管理UNDO DATA
同样的对于UNDO DATA而言也是有两种方法的,一种自动,一种手动
undo这个术语有点像rollback
undo的类型
system类用的是system tablespace
non-system类用别的tablespace,自动模式需要一个undospace,非自动模式私有的需要单个实例,公共的任何实例
延迟的,当使用时把tablespace设置为offline immediate,temporary,或者recovery


自动undo管理的概念:
undo data管理应用的是undo tablespace
你为工作实例用一个用足够的空间undo tablespace分配给每个实例。
配置自动undo需要用的到参数是undo_managerment和undo_tablespace
undo_managerment参数:特别的,显示undo是自动还是手动
undo_tablespace参数:显示正在使用的undo名称

通过以下语句可以建立一个undo tablespace:
这句是在建立DATABASE时候一起建立的
SQL>CREATE DATABASE db01 . . . UNDO TABLESPACE undo1 DATAFILE 'undo1db01.dbf'
SIZE 20M AUTOEXTEND ON;

这句是在以后建立的
SQL>CREATE UNDO TABLESPACE undo1 DATAFILE 'undo1db01.dbf' SIZE 20M


自动模式下修改undo tablespace:
使用方法用alter tablespace语句
修改方式用下列语句:
SQL>ALTER TABLESPACE undotbs ADD DATAFILE 'undotbs2.dbf' SIZE 30M AUTOEXTEND
ON;

自动模式下更改undo tablespace
交换到另外一个undotablespace,只有一个能被交换的实力,允许多个undo tablespace存在于一个实例,但只能激活一个。使用一个:
SQL>ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS2;

自动模式下删除undo tablespace
SQL>DROP TABLESPACE UNDOTBS2;

自动模式下其他的参数:
undo_supperss_errors 当为ture的时候将那些在手动处理的时候转会自动模式
undo_retention:Controls the amount of undo data to retain for
consistent read(翻译不出来)

查看undo data statistics
SQL>SELECT end_time,begin_time,undoblks FROM V$UNDOSTAT


在自动模式下修改undo tablespace的大小:
决定undo tablespace大小需要三个条件ur,ups,dbs
undospace=[ur*(ups*dbs)]+(dbs*24)

Undo Quota没有细研究,貌似E文都是概念性的东西

Undo下用到的视图为dba_rollback_segs,功能表达视图
V$ROLLNAME
V$ROLLSTAT
V$UNDOSTAT
V$SESSION
V$TRANSACTION

管理表~
Oracle中有很多datatype。详细的。。暂时不说
其次比较重要的rowid,rowid是唯一固定的,rowid的格式:
oooooofffbbbbbbrrr,oooooo是数据对象的号码fff是相对文件的数字bbbbbb是块号码rrr是行号码
restricted rowid format bbbbbbbbrrrrffff,bbbbbbbb是块号码rrrr是行码ffff是文件码

建表的语句是create table,建临时表create global temporary table

评论

此博客中的热门博文

Python学习笔记20100117

映射list   Dictionary 是用{}. list 是一那个[]. turple是用() 当你定义过dictionary后,你可以使用d.keys(), d.values(),d.items()将定义后的时候分别显示出来 当然可以将list里的值加减乘除,也可以如一般的定义直接重新复制这个list. 链接与分割字符串的 li=";", join(li) 则显示的就是 分隔符为;的数 如果使用li=li.split(";")则将刚刚;的分隔符删除,而split里也可定义域,如li.split(";",1)   自省 <---这是啥 之前在使用的时候发觉有些书本上的模块不能调用,很多是py脚本定义过的函数。 下载该脚本s,然后上传至指定位置。 >>>import sys >>>sys.path >>>sys.path.append("绝对位置")然后就能调用这些脚本和参数了。 删除 >>>sys.path.pop() 定义一个参数是 def info(test, test1=10.test2=12): info是函数名,test是必备参数,因为没有定义值,test1和test2是可选参数,定义了初始值   以上是外部函数的调用,下面转到内部函数 内部函数有type,str,dir及其他   ---type 返回任意字符的类型,模块也可以。types模块 >>> type(1) <type 'int'> >>> li=[] >>> type(li) <type 'list'> >>> import odbchelper >>> type(odbchelper) <type 'module'> >>> type(sys) <type 'module'> >>> import types ...

Setagaya park

  We visited Setagaya Park (世田谷区) yesterday. This park reminds us when we in Europe, which has a fancy fountain in the middle, and free entrance. People just laid down on the grass, enjoy the day time they can waste. people who have kids together,  play all different kinds of sports. you really can't image whether you are in Europe or  Japan. I would prefer to use a Bus instead of the metro, the metro is fast, but you only can see the dark, light, people sit or stand as Sardine, without any emotion. but on the bus, you can see the traffic, the shop, everything on the road. When we on our way to the park, we stop by a good chocolate shop named " craft chocolate works ",  this is a very good place to have ice cream, you probably can choose half & half, you can enjoy the feeling when you smell the chocolate smell and eat with it.  or you can enjoy beer or cake in "globe antiques (ザ グローブアン ティ ークス) .   also, we checked the Blue Bottle Coffee Sangenjaya ...