﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-java神谕-随笔分类-DataBase</title><link>http://www.blogjava.net/javaora/category/1925.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 14:47:54 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 14:47:54 GMT</pubDate><ttl>60</ttl><item><title>Oracle 笔记</title><link>http://www.blogjava.net/javaora/archive/2007/01/08/92429.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Mon, 08 Jan 2007 09:51:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2007/01/08/92429.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/92429.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2007/01/08/92429.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/92429.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/92429.html</trackback:ping><description><![CDATA[
		<p>Features and Contents of Control File<br />Is a binary file that is necessary for the database to start and operate successfully.<br />Every time an instance mounts an Oracle database, it reads the control file to locate the data files and online redo log files.<br />Is updated continuously during database use and must be available whenever the database is mounted or opened.<br />Provides information about database consistency used during recovery.<br />If any of the control files currently being used by the database becomes unavailable , then the database cannot function properly.<br />In summary, control file contains the following information<br />--Database name<br />--Data file location<br />--Redo log file location<br />--Tablespace names<br />--Current log sequence number<br />--Checkpoint information<br />--Log history<br />--Backup information</p>
		<p>////////////////////////////<br />Tablespaces<br />A tablespace can belong to only one database.<br />Each tablespace consists of one or more operating stystem files.<br />Tablespaces can be brought online while the database is running.<br />Except for the SYSTEM tablespace or a tablespace with an active rollback segment, tablespaces can be taken offline, leaving the database running.<br />Tablespaces can be swtiched between read-write and read-only status.<br />Controlling space allocation and assigning space quotas to users.<br />Controlling availability of data by taking individual tablespaces online or offline<br />Distributing data storage across devices to improve I/O performance and to reduce I/O contention agsinst a single disk.<br />Performing partial backup and partial recovery operations.<br />Keeping large amounts of static data on read-only devices.</p>
		<p>///////////////////////////<br />Data Files<br />Each tablespace in a Oracle consists of one or more files called data files. These are physical structures that conform with the operating system on which the Oracle Server us running.<br />An Oracle server creates a data file for a tablespace by allocating the specified amount of disk space plus a small overhead.<br />The database administrator can change the size of a data file after its creation or can specify that a data file should dynamically grow as objects in the tablespace grow.<br />/////////////////////////////////////<br />Segment<br />A segment is the space allocated for a specific type of logical storage structure within a tablespace. The following are example of segments:<br />--Table segment<br />--Index segment<br />--Temporary segment<br />--Rollback segment<br />A segment such as a data segment may span multiple files that belong to the same tablespace.</p>
		<p>/////////////////////////////////////<br />Extents <br />An extends is a set contiguous number of blocks.<br />Each type of segment is made up of one or more extents.<br />An extent may not span a data file, but muts exist in one data file.</p>
		<p>/////////////////////////////////////////////////////<br />Data Blocks<br />At the finest level of granularity , the data in an Oracle database is stored in data blocks.<br />One data block corresponds to one or more physical file blocks allocated from an existing data file.<br />Data block size is specified for each Oracle database by the initialization parameter DB_BLOCK_SIZE when the database is created.<br />The samllest unit of input-output.</p>
		<p>//////////////////////////////////////////////////////</p>
		<p>SYSTEM and Non-SYSTEM Tablespaces<br />SYSTEM Tablespace<br />Automatic created after the database is created<br />Required in all databases for database operation.<br />Contains data dictionary information, definitions of stored procedures, packages, and database triggers.<br />Contains the SYSTEM rollback segment.<br />Should not contain use data although it is allowed.</p>
		<p>Non-SYSTEM Tablespace<br />Enable more flexibility in database administration<br />Can store rollback segments,temporary segments, application data, and application indexes.</p>
		<p>
				<br />CREATE TABLESPACE app_data<br />DATAFILE '/DISK4/app01.dbf' SIZE 100M,<br />         '/DISK5/app02.dbf' SIZE 100M<br />MINIMUM EXTENT 500K<br />DEFUALT STORAGE(INITIAL 500K<br />                NEXT    500K<br />                MINEXTENTS 3<br />                MAXEXTENTS 500<br />                PCTINCREASE 50);</p>
		<p>Method 1: Adding Data Files to a Tablespace<br />ALTER TABLESPACE app_data ADD DATAFILE<br /> '/DISK5/app03.dbf' SIZE 200M;<br /> </p>
		<p>Method 2: Enabling Automatic Extension of new created Data Files<br />ALTER TABLESPACE app_data ADD DATAFILE<br />'/DISK6/app04.dbf'  SIZE 200M<br />AUTOEXTEND ON NEXT 10M MAXSIZE 500M;<br />               <br />Method 3: Enabling Automatic Extension of existing Data Files<br />ALTER DATABASE <br />DATAFILE '/DISK5/app03.dbf'<br />AUTOEXTEND ON NEXT 10M MAXSIZE 500M;</p>
		<p>Method 4:Changing the Size of Data Files Manually<br />ALTER DATABASE DATAFILE '/DISK5/app02.dbf'<br />RESIZE 200M;</p>
		<p>
				<br />READ-ONLY tablespace<br />Making tablespaces read-only prevents further write operations on the data files. The purpose of read-only tablespaces is to ensure that on changes are made and to eliminate the need to perform backup and recovery of large, static portions of a database. The Oracle server never updates the files of a read-only tablespace, and therefore the files can reside on read-only media, such as CD ROMs or WORM drives.</p>
		<p>Making tablespace APP_DATA only available for read operations.<br />ALTER TABLESPACE app_data READ ONLY;</p>
		<p>DBA_TABLESPACES</p>
		<p>/////////////////////////////////////////////////////<br />Storage Structure and Relationships</p>
		<p> </p>
		<p>select a.segment_name,a.tablespace_name,a.extents,a.blocks<br /> from dba_segments a<br /> where owner='TPL'<br /> <br /> <br /> select a.extent_id,a.file_id,a.block_id,a.blocks from dba_extents a where owner='TPL'<br /> <br /> <br />select tablespace_name  ,count(*),max(blocks),sum(blocks)<br />from dba_free_space <br />group by tablespace_name</p>
		<p>//////////////////////////////////////<br />Rollback Segment<br />Purpose of Rollback Segment</p>
		<p>Transaction Rollback</p>
		<p>When a transaction makes changes to a row in a table, the old image is saved in the rollback segment. If the transaction is rolled back, the value in the rollback segment is written back to the row, restoring the original value.</p>
		<p>Read Consistency<br />When transactions are in progress, other users in the database should not see any uncommitted changes made by these transactions. In addition, a statement should not see any changes that were committed after the statement commences execution. The old values in the rollback segments are also used to provide the readers a consistent image for a given statement.</p>
		<p>Transaction Recovery<br />If the instance  fails when transactions are in progress, Oracle server needs to rollback the uncommitted changes when the database is opened again. This rollback is known as transaction recovery and is only possible if changes made to the rollback segment are also protected  by the redo log files.</p>
		<p>/////////////////////////////////////////<br />How transactions use Rollback Segment<br />1.When a transaction begins, a rollback segment needs to be assigned to this transaction.<br />2.A transaction may request a specific rollback segment using the following command:<br />  SET TRANSACTION USE ROLLBACK SEGMENT rollback_segment<br />3.If no such request is made, the Oracle server chooses the rollback segment with the fewest transactions, and assigns it to the transaction.<br />4.Transactions use extends of a rollback segment in an ordered circular fashion, moving from one to the next after the current extent is full. <br />5.The pointer or the head of the rollback segment moves to the next extent when the current extet is full.<br />6.The OPTIMAL parameter specifies the size in bytes that a rollback segment must shrink to, if possible. Specifying OPTIMAL minimizes the waste of space in a rollback segment. If the OPTIMAL parameter is specified, a rollback segment can release space on completion of transactions that caused the growth.</p>
		<p>
				<br />create rollback segment rbs01<br />tablespace USERS<br />storage (initial 100k<br />         next    100k<br />         optimal 4M<br />         minextents 20<br />         maxextents 100);</p>
		<p>alter rollback segment rsb01 online;</p>
		<p>alter rollback segment rsb01 offline;</p>
		<p>drop rollback segment rsb01;</p>
		<p>select a.USN,a.EXTENTS,a.OPTSIZE,a.HWMSIZE,a.XACTS,a.STATUS from v$rollstat a</p>
		<p>//////////////////////////////////////////////////<br />Temporary Segment<br />Temporary segment are used when statement such as the following are executed and the Oracle server cannot perform the sorting needed in memory because it is bigger that SORT_AREA_SIZE.<br />--SELECT ...ORDER BY<br />--CREATE INDEX<br />--SELECT DISTINCT<br />--SELECT...GROUP BY<br />The amount of memory used by a process for sorting  is determined by the SORT_AREA_SIZE initialization parameter. If the sort volume exceeds this size, serveral sort runs are needed, and intermedidate results are stored on disk.<br />Temporary segments are created and used by the Oracle server in the tablespace that has been assigned to the user for sorting.</p>
		<p>Temporary Segments in a Temporary Tablespace<br />Known as sort segments<br />Only one segment per tablespace per instance<br />Created when the first disk sort occurs in the instance after startup<br />Reused by serveral transactions based on information in the SORT Extent Pool<br />Release on instance shutdown.</p>
		<p>select *from v$sort_segment</p>
		<p>select * from v$sort_usage</p>
		<p>///////////////////////////////////<br />Managing Indexes</p>
		<p>B-Tree Index<br />////////////////////////////////////////////////////////////<br /></p>
<img src ="http://www.blogjava.net/javaora/aggbug/92429.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2007-01-08 17:51 <a href="http://www.blogjava.net/javaora/archive/2007/01/08/92429.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>修改MS SQL的用户数限制</title><link>http://www.blogjava.net/javaora/archive/2005/07/01/6990.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Fri, 01 Jul 2005 05:52:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2005/07/01/6990.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/6990.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2005/07/01/6990.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/6990.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/6990.html</trackback:ping><description><![CDATA[&nbsp;MS SQL有许多默认值是可以修改的，比如:MS SQL默认的用户连接数是15，一旦使用某数据库服务器的人多了的时候，特别是一些用户喜欢打开多个连接的时候，经常造成超过连接数而使一些人连接不上。 <PRE>sp_configure语法：sp_configure [_name[,_value]]
</PRE>
<P><FONT color=#ffffff>----</FONT> 在MS SQL中，以"user connection"标记用户数目，所以作如下修改： 
<P><FONT color=#ffffff>----</FONT> 1、以管理员帐号登录进MS SQL数据库服务器； 
<P><FONT color=#ffffff>----</FONT> 2、运行sp_configure系统存储过程：在Isq_w或Enterprise Manager中的SQL Query Tool中敲入： <PRE>sp_configure "user connections", 150
go          --如果愿意选比150更大的数字当然可以。
    --最大只能是32767
RECONFIGURE
Go
</PRE><PRE></PRE>3、执行敲入的SQL语句； <PRE></PRE>4、关闭SQL服务，（在EnterPrise Manger中选中服务器，点右鼠标键，选stop，再选start.大功告成！ <PRE></PRE>为什么要执行第四步？Sp_configure所带的参数分两类，动态与静态，动态参数不需要重新启动服务器，运行sp_configure和recnfigure后就改变了，而静态参数要重新启动后才能改变。上面的"user connections"就是静态参数。 <img src ="http://www.blogjava.net/javaora/aggbug/6990.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2005-07-01 13:52 <a href="http://www.blogjava.net/javaora/archive/2005/07/01/6990.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>