純好人不用打:白羊
沒(méi)人防:雙子(迷宮)、天平(卡妙的冰箱)、射手(迷宮)
打死:巨蟹(紫龍)、山羊(紫龍自曝)、雙魚(yú)(阿瞬)、水瓶(冰河)
沒(méi)打過(guò),放水:獅子(星矢)、天蝎(冰河)、金牛(星矢)、處女(一輝)
這樣看來(lái)紫龍是最NB的,一個(gè)人干掉2個(gè),而且靠他師傅走后門(mén)天平不用打,還用天平的武器救了冰河。
冰河和他師傅干了2仗
冰河那段也挺NB,先是在天平被凍個(gè)半死,然后在天蝎被針扎個(gè)半死,最后到了水瓶還能把他師傅干掉
冰河和他師傅是最體現(xiàn)實(shí)力的一仗,純實(shí)力對(duì)扣
合著星矢誰(shuí)也沒(méi)殺,就TM來(lái)打醬油的。。。
簡(jiǎn)單過(guò)一遍,詳細(xì)的以后遇到慢慢研究。
主要的更新在幾個(gè)方面:
1. OUI的改進(jìn)
2. Oracle Restart
3. ASM的增強(qiáng)!!!
New Grid Infrastructure Installation Option
?1. 單點(diǎn)包括:ASM、listener和Oracle Restart(監(jiān)控、管理并自動(dòng)重啟各個(gè)組件)
?2. 集群包括:ASM、listener和Clusterware
New Desktop and Server Class Options?1. Desktop Class:適用于筆記本、臺(tái)式機(jī)
?2. Server Class:適用于服務(wù)器(功能上沒(méi)區(qū)別,多一些高級(jí)配置選項(xiàng))
Daylight Savings Time Upgrade of Timestamp with Timezone Data Type?新的DBMS_DST包,優(yōu)化對(duì)TIMESTAMP WITH TIMEZONE數(shù)據(jù)的管理
SYSASM Privilege?管理ASM需要SYSASM權(quán)限,旨在分清ASM管理和DB管理
Fixup Scripts and Prerequisite Checks?安裝前檢查時(shí),如果遇到不符合要求的配置,OUI會(huì)對(duì)一些檢查項(xiàng)自動(dòng)生成fixup腳本,用root執(zhí)行就可以解決相應(yīng)問(wèn)題。
New Tool to Configure Custom Installation Options?OUI不在提供對(duì)單個(gè)組件的配置功能,如果需要只能用$ORACLE_HOME/bin/chopt命令行進(jìn)行配置。
我想Oracle的趨勢(shì)就是為了讓更多已經(jīng)成熟的配置自動(dòng)化,簡(jiǎn)化使用。Deinstallation Tool?OUI不再用來(lái)刪除oracle軟件,請(qǐng)使用$ORACLE_HOME/deinstall
Intelligent Data Placement?指定ASM磁盤(pán)的磁盤(pán)范圍,旨在將高頻訪問(wèn)的數(shù)據(jù)放在HOT region(比如磁盤(pán)的外道)
Oracle Automatic Storage Management Cluster File System (Oracle ACFS)?為其它文件提供ASM的存儲(chǔ)功能
Data Pump Export and Data Pump Import?Data Pump兼容Export/Import
Use Oracle Restart to Automatically Restart Your Database?1. 針對(duì)單點(diǎn)環(huán)境
?2. 自動(dòng)重啟又問(wèn)題的組件,如:db instance、listener、asm instance
New Method of Installing Oracle Automatic Storage Management?以前,ASM的安裝是伴隨著DB的安裝;現(xiàn)在是伴隨著Software的安裝。
?其實(shí),就是把ASM上升到一個(gè)軟件的高度(以前只是db的一個(gè)組件)
SRVCTL Support for Single Instance Database in a Cluster?SRVCTL統(tǒng)一管理單點(diǎn)(with Restart)和集群數(shù)據(jù)庫(kù)(with Clusterware)
Deprecated in Oracle Database 11g Release 2?不支持裸設(shè)備了:要么用文件系統(tǒng)、要么用ASM,說(shuō)白了,
企業(yè)環(huán)境就必須用ASM?不支持Oracle Ultra Search(9i的一個(gè)什么鳥(niǎo)功能)
重裝完系統(tǒng),mysql不需要重裝,直接當(dāng)綠色版使用,還更干凈
//啟動(dòng)MYSQL
cd $MYSQL_HOME/bin
D:\JAVA\MYSQL\mysql-5.1.53-win32\bin>
mysqld --console??????
110616? 1:26:26 [Note] Plugin 'FEDERATED' is disabled.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
110616? 1:26:26? InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
110616? 1:26:26? InnoDB: Started; log sequence number 0 44233
110616? 1:26:27 [Note] Event Scheduler: Loaded 0 events
110616? 1:26:27 [Note] mysqld: ready for connections.
Version: '5.1.53-community'? socket: ''? port: 3306? MySQL Community Server (GPL
)
//簡(jiǎn)單使用mysql>
show databases;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| test?????????????? |
+--------------------+
3 rows in set (0.03 sec)
mysql>
use mysqlDatabase changed
mysql>
show tables;+---------------------------+
| Tables_in_mysql?????????? |
+---------------------------+
| columns_priv????????????? |
| db??????????????????????? |
| event???????????????????? |
| func????????????????????? |
| general_log?????????????? |
| help_category???????????? |
| help_keyword????????????? |
| help_relation???????????? |
| help_topic??????????????? |
| host????????????????????? |
| ndb_binlog_index????????? |
登陸D:\JAVA\MYSQL\mysql-5.1.53-win32\bin>mysql.exe -uroot
創(chuàng)建數(shù)據(jù)庫(kù)mysql> create database testdb;
--主鍵是非分區(qū)索引,也可以看作是全局
create table test_par1
(
? tdate?? varchar2(8)
primary key)
partition by range ( tdate )
(
???? partition p1 values less than ('20090201'),
???? partition p2 values less than ('20090301'),
???? partition pm values less than (MAXVALUE) ?
) tablespace test;
--主鍵是分區(qū)索引create table test_par2
(
? tdate?? varchar2(8)
)
partition by range ( tdate )
(
???? partition p1 values less than ('20090201'),
???? partition p2 values less than ('20090301'),
???? partition pm values less than (MAXVALUE) ?
) tablespace test;
create index i_tdate2 on test_par2(tdate)
local;
alter table test_par2
add constraint pk_tdate2
primary key(tdate);
--查看test_par2的DDL
select dbms_metadata.get_ddl( 'TABLE', 'TEST_PAR2' ) from dual;
--整理如下create table test_par3
(
? tdate?? varchar2(8),
? constraint pk_tdate3 primary key (tdate)
using index local)
partition by range ( tdate )
(
???? partition p1 values less than ('20090201'),
???? partition p2 values less than ('20090301'),
???? partition pm values less than (MAXVALUE) ?
) tablespace test;
這個(gè)案例也告訴我們,在做DDL時(shí),盡量還是顯示的寫(xiě)出屬性,一些簡(jiǎn)易語(yǔ)法會(huì)引起不可知的定義。最后都用 get_ddl 再查一下,這才是Oracle真正執(zhí)行的DDL。
列出所有實(shí)例
[db2inst1@dcm ~]$ db2ilist
db2inst1
列出當(dāng)前實(shí)例下的所有數(shù)據(jù)庫(kù)[db2inst1@dcm ~]$ db2 list db directory
?System Database Directory
?Number of entries in the directory = 1
Database 1 entry:
?Database alias?????????????????????? = SAMPLE
?Database name??????????????????????? = SAMPLE
?Local database directory???????????? = /home/db2inst1
?Database release level?????????????? = d.00
?Comment????????????????????????????? =
?Directory entry type???????????????? = Indirect
?Catalog database partition number??? = 0
?Alternate server hostname??????????? =
?Alternate server port number???????? =
啟動(dòng)實(shí)例[db2inst1@dcm ~]$ db2start
07/09/2010 14:24:36???? 0?? 0?? SQL1063N? DB2START processing was successful.
SQL1063N? DB2START processing was successful.
連接到數(shù)據(jù)庫(kù)[db2inst1@dcm ~]$ db2 connect to sample
?? Database Connection Information
?Database server??????? = DB2/LINUX 9.7.1
?SQL authorization ID?? = DB2INST1
?Local database alias?? = SAMPLE
執(zhí)行SQL[db2inst1@dcm ~]$ db2
db2 => select * from staff where dept=20
ID???? NAME????? DEPT?? JOB?? YEARS? SALARY??? COMM??? ?
------ --------- ------ ----- ------ --------- ---------
??? 10 Sanders?????? 20 Mgr??????? 7? 98357.50???????? -
??? 20 Pernal??????? 20 Sales????? 8? 78171.25??? 612.45
??? 80 James???????? 20 Clerk????? -? 43504.60??? 128.20
?? 190 Sneider?????? 20 Clerk????? 8? 34252.75??? 126.50
? 4 record(s) selected.
退出db2 => quit
DB20000I? The QUIT command completed successfully.
斷開(kāi)連接(不斷開(kāi)就不能db2stop)[db2inst1@dcm ~]$ db2 connect reset
DB20000I? The SQL command completed successfully.
關(guān)閉實(shí)例[db2inst1@dcm ~]$ db2stop
07/09/2010 14:29:32???? 0?? 0?? SQL1064N? DB2STOP processing was successful.
SQL1064N? DB2STOP processing was successful.
最近初探了一下DB2,發(fā)現(xiàn)關(guān)于“數(shù)據(jù)庫(kù)”、“實(shí)例”的概念及其關(guān)系容易把人弄暈,這里小小總結(jié)一下,并把Oracle也拉進(jìn)來(lái)一起整。
另外,發(fā)現(xiàn)Oracle和IBM老搞一些理論上就針?shù)h相對(duì)的事情,如RAC vs DPF (database partitioning feature),很是有趣。
基本概念還是相同的
數(shù)據(jù)庫(kù)軟件(下面簡(jiǎn)稱(chēng)軟件):軟件本身,一臺(tái)主機(jī)安裝一套就可以了。(拋開(kāi)你故意在一臺(tái)服務(wù)器上安裝2遍Oracle/DB2這種不正常思維)
實(shí)例:數(shù)據(jù)庫(kù)
軟件啟動(dòng)后的“進(jìn)程+內(nèi)存”
軟件+實(shí)例的關(guān)系:一臺(tái)電腦只需要按照一套QQ(軟件),但是我們可以多用戶(hù)登錄(實(shí)例)。換到哲學(xué)的角度,就是抽象和具體的關(guān)系。
數(shù)據(jù)庫(kù)(狹義,下面簡(jiǎn)稱(chēng)庫(kù)):一堆文件(數(shù)據(jù)文件、控制文件、日志文件、參數(shù)文件)
它和軟件的區(qū)別:軟件是廠商賣(mài)給你的東西;
庫(kù)是你自己的東西(業(yè)務(wù)、應(yīng)用)
它和實(shí)例的關(guān)系:用戶(hù)需要借助實(shí)例(所提供的各種手段)來(lái)訪問(wèn)
庫(kù)庫(kù)就相當(dāng)于是QQ聊天記錄
最后:數(shù)據(jù)庫(kù)(廣義)= 軟件 + 實(shí)例 + 庫(kù)一臺(tái)服務(wù)器(即一套數(shù)據(jù)庫(kù)軟件)可以建多個(gè)實(shí)例,多個(gè)庫(kù),且互不相干
體系結(jié)構(gòu)的不同之處Oracle? 實(shí)例和庫(kù)一一對(duì)應(yīng)
DB2???? 一個(gè)實(shí)例可以?huà)於鄠€(gè)庫(kù)
高級(jí)情況(簡(jiǎn)單提一下,以后再慢慢研究)Oracle:RAC一個(gè)庫(kù)被多個(gè)實(shí)例掛
DB2:DPF一個(gè)實(shí)例多個(gè)庫(kù)
在數(shù)據(jù)庫(kù)集群模式設(shè)計(jì)方面,有Share everything架構(gòu)和Share nothing架構(gòu),前者以O(shè)RACLE RAC為代表,IBM DB2 Purescale為挑戰(zhàn)者;后者以IBM DB2 DPF為代表。
行鏈接:
1. 一條記錄的大小大于block size,則產(chǎn)生行鏈接
2. 容易發(fā)生在比較大的行上
3. 因?yàn)樾墟溄邮怯蒬b_block_size不夠大引起的,所以對(duì)已有的行鏈接是無(wú)法清除的
4. 9i以后,可以對(duì)不同的表空間設(shè)置不同的db_block_size,可以將一些特殊的寬表放在大block size的表空間
例子:
表空間block size為8k(8192),因?yàn)閿?shù)據(jù)塊頭也要占一定空間,所以如下例,實(shí)際只能放7948的數(shù)據(jù),一旦超過(guò),就產(chǎn)生行鏈接
--無(wú)
create table test7948(a char(2000),b char(2000),c char(2000),d char(1948))
tablespace test;
insert into test7948 values('a','b','c','d');
commit;
--有
create table test7949(a char(2000),b char(2000),c char(2000),d char(1949))
tablespace test;
insert into test7949 values('a','b','c','d');
commit;
行遷移:1. 本來(lái)是放的下的
2. 因?yàn)楦率箁ow size變大了,一個(gè)block里又不足以放下增加的空間(PCTFREE相關(guān)),則產(chǎn)生行遷移
3. 容易發(fā)生在PCTFREE較小,對(duì)類(lèi)似varchar類(lèi)型的update又很多的表上
4. 無(wú)法避免,但通過(guò)把數(shù)據(jù)導(dǎo)出導(dǎo)入進(jìn)行清除
例子:
--無(wú)
create table test7948_vchar(a char(2000),b char(2000),c char(2000),d char(1940), e varchar(9))
tablespace test;
insert into test7948_vchar values('a','b','c','d','12345678');
commit;
一更新,使得row size大于7948了,產(chǎn)生行遷移
--有
update test7948_vchar set e='123456789'
隨著Oracle收購(gòu)SUN,今天又爆出SAP收購(gòu)Sybase的大料。
現(xiàn)狀:
Oracle和IBM已經(jīng)成為諾亞方舟級(jí)的廠商,啥都有。
微軟,SAP成為航母級(jí)的廠商,軟件方面啥都有,但目前沒(méi)有硬件。
猜想:who's next? Dell? HP?
不然微軟把Dell收了吧,組成BDll公司;
然后SAP和HP合并為SHP
--創(chuàng)建一個(gè)大一點(diǎn)的TEMP表空間
create temporary tablespace temp1
tempfile '/oracledatafile/temp01.dbf' SIZE 100m autoextend on next 100m maxsize 5000m;
?
--切換默認(rèn)TEMP表空間
alter database default temporary tablespace temp1;
--刪掉以前的TEMP表空間
drop tablespace temp including contents and datafiles;
1. 物化視圖由于是物理真實(shí)存在的,故可以創(chuàng)建索引。
--為基表創(chuàng)建MLOG
--創(chuàng)建物化視圖時(shí)應(yīng)先創(chuàng)建存儲(chǔ)的日志空間,否則建MV時(shí)報(bào)錯(cuò)
--ORA-23413: table "SCOTT"."EMP" does not have a materialized view log
create materialized view log on
scott.emptablespace test
/
--創(chuàng)建物化視圖create materialized view test_mv
tablespace test
parallel (degree 4)
build immediate refresh fast
enable query rewrite
as
select * from
scott.emp/
--查看一下結(jié)果,果然很符合物化視圖的定義,一個(gè)表+一個(gè)視圖SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
OBJECT_NAME??? OBJECT_TYPE
-----------??? --------
TEST_MV??? ??? TABLE
TEST_MV??? ??? MATERIALIZED VIEW
SQL> select mview_name, container_name from user_mviews;
MVIEW_NAME?????? CONTAINER_NAME
---------------- ------------------------------
TEST_MV????????? TEST_MV?
(這就是那個(gè)存儲(chǔ)表)--查看MLOG的情況--注意:MLOG的所屬和MV的所屬并不是同一個(gè)SQL> select log_owner, master, log_table from dba_mview_logs
LOG_OWNER??? MASTER??? LOG_TABLE
---------------------------------
SCOTT??? ??? EMP??? MLOG$_EMP
(MLOG其實(shí)也就是一個(gè)表)SQL> desc scott.
mlog$_emp;
Name??? ??? ??? Type
-------------------------------
EMPNO??? ??? ??? NUMBER(4)
SNAPTIME$$??? ??? DATE
DMLTYPE$$??? ??? VARCHAR2(1)
OLD_NEW$$??? ??? VARCHAR2(1)
CHANGE_VECTOR$$??? ??? RAW(255)
--刪除MLOGdrop materialized view log on 物化視圖所依賴(lài)的表名;?
--刪除物化視圖drop materialized view 物化視圖名;
注意,為了能在終端看見(jiàn)put_line的輸出,還需要先開(kāi)啟
set serveroutput on
?
--用來(lái)測(cè)試的表create table test_tri(
a1 int,
a2 int
)
tablespace test
-----行級(jí)insert觸發(fā)器-----
1) 插入的一行新數(shù)據(jù)保存在:new
2) insert觸發(fā)器沒(méi)有:old值3) 對(duì):new的修改,只能定義在before類(lèi)型的觸發(fā)器中---觸發(fā)器語(yǔ)法---create or replace trigger 名稱(chēng)
[after|before] [delete|update|insert]
[of 列名] [on 表名]
[referencing new as 新行別名 old as 舊行別名]
[for each row] [when(條件)]
declare
....
begin
...
exception
....
end; --定義create or replace trigger test_before_insert
before insert on test_tri
for each row
when(new.a2 is null)begin
?? ?dbms_output.put_line('insert row original: a1=' || :new.a1 || ' a2=' || :new.a2);
?? ?:new.a2 := :new.a1 * 2;? ?
end;
/
create or replace trigger test_after_insert
after insert on test_tri
for each row
begin
?? ?dbms_output.put_line('insert row actual: a1=' || :new.a1 || ' a2=' || :new.a2);? ?
end;
/
--測(cè)試SQL> insert into test_tri(a1) values(1);
insert row original: a1=1
a2=insert row actual: a1=1 a2=2
SQL> insert into test_tri values(2,3);
insert row actual: a1=2 a2=3
SQL> select * from test_tri;
??????? A1???????? A2
---------- ----------
???????? 1?????????
2(由觸發(fā)器生成的值)???????? 2????????? 3
-----DDL觸發(fā)器-----
--任何create語(yǔ)句都會(huì)觸發(fā)這個(gè)語(yǔ)句create or replace trigger test_ddl_trigger
before create on schema
begin
??? dbms_output.put_line( 'DDL Trigger' );
??? insert into test_tri values(9,9);
end;
Oracle建好后,tnsnames和listener中自動(dòng)就帶有如下內(nèi)容,這里咱們就來(lái)解釋一下這些東西是干什么用的
----TNSNAMES.ora----
EXTPROC_CONNECTION_DATA =
? (DESCRIPTION =
??? (ADDRESS_LIST =
????? (ADDRESS = (PROTOCOL =
IPC)(KEY =
EXTPROC1))
??? )
??? (CONNECT_DATA =
????? (SID =
PLSExtProc)
????? (PRESENTATION = RO)
??? )
? )
----LISTENER.ora----SID_LIST_LISTENER =
? (SID_LIST =
??? (SID_DESC =
????? (SID_NAME =
PLSExtProc)
????? (ORACLE_HOME = /opt/oracle/10gR2)
????? (PROGRAM =
extproc)
??? )
? )
LISTENER =
? (DESCRIPTION_LIST =
??? (DESCRIPTION =
????? (ADDRESS = (PROTOCOL =
IPC)(KEY =
EXTPROC1))
????? (ADDRESS = (PROTOCOL = TCP)(HOST = dcm)(PORT = 1521))
??? )
? )
IPC - Inner Process CommunicationWhen a process is on the same machine as the server, use the IPC protocol for connectivity instead of TCP. Inner Process Communication on the same machine does not have the overhead of packet building and deciphering that TCP has.
I've seen a SQL job that runs in 10 minutes using TCP on a local machine run as fast as one minute using an IPC connection. The difference in time is most dramatic when the Oracle process has to send and/or receive large amounts of data to and from the database.
For example, a SQL*Plus connection that counts the number of rows of some tables will run about the same amount of time, whether the database connection is made via IPC or TCP. But if the SQL*Plus connection spools much data to a file, the IPC connection will often be much faster -- depending on the data transmitted and the machine workload on the TCP stack.
For how to configure it:
1. you should add one IPC line in the LISTENER.ORA
2. You should also add one IPC line in the TNSNAMES.ORA
PLSExtPro - PL/Sql External Procdure默認(rèn)安裝時(shí),會(huì)安裝一個(gè)PL/SQL外部程序(
extproc--這是程序名)條目在listener.ora中,是oracle為調(diào)用外部程序默認(rèn)配置的監(jiān)聽(tīng),它的名字(也就是SID)通常是ExtProc或
PLSExtProc。
但一般不會(huì)使用它,可以直接從listener.ora中將這項(xiàng)移除,因?yàn)閷?duì)ExtProc已經(jīng)有多種攻擊手段了,在不使用外部程序時(shí),Oracle也是建議刪除的。
extproc的作用就是在pl/sql中調(diào)用
外部語(yǔ)句,如c,java寫(xiě)的過(guò)程。
現(xiàn)在,Oracle已經(jīng)全面支持JAVA了,這東西也就過(guò)時(shí)了,之所以繼續(xù)保留是考慮到兼容以前老版本的數(shù)據(jù)庫(kù)實(shí)例。
[oracle@dcm bin]$ extproc
Oracle Corporation --- TUESDAY?? JAN 05 2010 21:58:23.878
Heterogeneous Agent Release 10.2.0.1.0 - Production
--登錄sys用戶(hù),創(chuàng)建一個(gè)測(cè)試用戶(hù),權(quán)限可以給大點(diǎn)
SQL> create user test identified by xxxxx;
SQL> grant connect to test;
SQL> grant resource to test;
SQL> grant dba to test;
--登錄test用戶(hù),開(kāi)始測(cè)試--建個(gè)測(cè)試表create table test_table(id int, time timestamp);
--創(chuàng)建Jobbegin
dbms_scheduler.create_job(
?? ?job_name => 'test_job',
?? ?job_type => 'PLSQL_BLOCK',
?? ?job_action => 'insert into test_table
????????????????? (select
nvl(max(id),0)+1, systimestamp from test_table, dual);',
--nvl函數(shù)同SQLServer的isnull函數(shù)?? ?start_date => null,
--一激活,就開(kāi)始?? ?repeat_interval => '
FREQ=SECONDLY;INTERVAL=10');
end;
FREQ用來(lái)指定間隔的時(shí)間周期,可選參數(shù)有:YEARLY,MONTHLY,WEEKLY,DAILY,HOURLY,MINUTELY,SECONDLY。--光創(chuàng)建沒(méi)用,還需要激活;也可以在創(chuàng)建時(shí),直接把enable屬性設(shè)置為true(enabled => true)select job_name, enabled, run_count from user_scheduler_jobs;
JOB_NAME?????????????????????? ENABL? RUN_COUNT
------------------------------ ----- ----------
TEST_JOB?????????????????????? FALSE????????? 0begin
dbms_scheduler.enable('test_job');
end;
--查看效果select id, to_char(time,'HH24:MI:SS:FF3') from test_table;
?
????? ID? TO_CHAR(TIME,'HH24
---------- ------------------
???????? 1 16:13:29:542
???????? 2 16:13:39:506
???????? 3 16:13:49:109
???????? 4 16:13:59:097
???????? 5 16:14:09:109
???????? 6 16:14:19:103
???????? 7 16:14:29:101
???????? 8 16:14:39:099
???????? 9 16:14:49:105
??????? 10 16:14:59:100--停止任務(wù)begin
dbms_scheduler.disable('test_job');
end;
--刪除任務(wù)begin
dbms_scheduler.drop_job('test_job');
end;
一致和并發(fā)是對(duì)立的,需要根據(jù)應(yīng)用,選擇權(quán)宜之計(jì)
數(shù)據(jù)不一致的現(xiàn)象
---事務(wù)內(nèi)單SQL的情況---
1.
臟讀-Dirty Read:本事務(wù)讀取了其它事務(wù)尚未提交的修改數(shù)據(jù)
例子:讀了不該讀的
1:00 x=1
1:01 A用戶(hù) Update x=2(但未commit)
1:02 B用戶(hù) Select x --> x=2
合理的情況是x仍然等于1---事務(wù)內(nèi)多SQL的情況(典型的如,先查再改)---2.
不可重復(fù)讀-Non Repeatable Read
例子1:自相矛盾
1:00 x=1 y=2
1:01 B用戶(hù) Select x,y --> x=1 y=2
1:02 A用戶(hù) Update x=2; Commit;
1:03 B用戶(hù) Select x+y --> x+y=4
首先這個(gè)結(jié)果從單條SQL的角度看,是沒(méi)有問(wèn)題的。但是,如果把B的兩次查詢(xún)看作一個(gè)整體(事務(wù)),那么合理的情況應(yīng)該是
? x+y仍然等于3
? 或者B再進(jìn)行一次事務(wù),得出 x=2 y=2 x+y=4 的結(jié)果例子2:更新丟失
1:00 x=1
1:01 B用戶(hù) Select x --> x=1
1:02 A用戶(hù) Select x --> x=1
1:03 A用戶(hù) Update x=2; Commit;
1:04 B用戶(hù) Update x=3; Commit;
同樣,從單條SQL來(lái)講,沒(méi)有任何問(wèn)題。
但是從邏輯的合理性講,一般的更新操作都是先查再改,換言之
? A真正想做的是Update x from 1 to 2
? B真正想做的是Update x from 1 to 3
但最終卻造成了在B不知情的情況下,把B的初衷改為了Update x from 2 to 33.
幻影讀-Phantom Read
例子:讀到了未來(lái)
1:00 X1=1 X2=2
1:01 B用戶(hù) Select Xi --> X1=1 X2=2
1:02 A用戶(hù) Insert X3=3; Commit;
1:03 B用戶(hù) Select sum(Xi) --> re=6
其實(shí)道理和之前的不可重復(fù)讀相同,只不過(guò)是由Insert引起的罷了。
(甚至Delete也會(huì)引起類(lèi)似的問(wèn)題,但好像學(xué)術(shù)界并沒(méi)有對(duì)Delete進(jìn)行討論)Isolation LevelRead Uncommitted:1,2,3都會(huì)發(fā)生
? Oracle中嚴(yán)格禁止臟讀
? 在SQL Server 7.0中,是可以選擇該級(jí)別的
Read Committed:發(fā)生2,3(Oracle的默認(rèn)級(jí)別)
Repeatable Read:發(fā)生3
Serializable:都不發(fā)生
Oracle的實(shí)現(xiàn)方式Read Committed:默認(rèn)就實(shí)現(xiàn)
Repeatable Read:
? 1. 悲觀鎖(select ... for update),影響并發(fā)
? 2. 樂(lè)觀鎖(update where 所有字段都作為條件),不影響并發(fā)
Serializable:
? alter session set isolation_level=serializable/read only
因?yàn)樵诳蛻?hù)那工作不能上網(wǎng),決定辦一張3G上網(wǎng)卡(公司報(bào)銷(xiāo)),中午分別去電信和移動(dòng)了解了一下:
電信 960元? 7個(gè)月? 300小時(shí)/月
移動(dòng) 880元? 7個(gè)月? 15G/月 (目前推廣期,不限流量)
(都包含上網(wǎng)貓)
這樣算下來(lái)還是移動(dòng)的便宜,去搞了個(gè)移動(dòng)的。
關(guān)于移動(dòng)的上網(wǎng)貓,開(kāi)始給我測(cè)試的時(shí)候用的是華為的、白色、流線(xiàn)型還挺好看。最終給我的是一個(gè)鳥(niǎo)公司的(敏訊),方形真難看,太大了,號(hào)稱(chēng)還是升級(jí)版。
速度嘛,看網(wǎng)頁(yè)沒(méi)啥問(wèn)題,Outlook下郵件也很快,在線(xiàn)聽(tīng)歌也沒(méi)問(wèn)題,在線(xiàn)電影就不去嘗試了,免得傷自尊,辦公足夠了。玩開(kāi)心網(wǎng)有點(diǎn)卡。(我以前就用過(guò)聯(lián)通的CDMA-2G上網(wǎng),那叫一個(gè)慢呀)
這個(gè)帖子就是用3G網(wǎng)絡(luò)發(fā)的,哈哈。同時(shí)紀(jì)念一下2年后重回BMW做項(xiàng)目。
扇區(qū)(sector):最小的可尋址單元,512byte
磁道(track):一圈扇區(qū)
磁柱(cylinder):一摞磁道
每一磁道的扇區(qū)數(shù)是一樣的,但是存儲(chǔ)密度不同,外疏內(nèi)密。
為什么要外疏內(nèi)密?
角速度相同時(shí),線(xiàn)速度與半徑成正比:
硬盤(pán)為了提高其軸壽命,軸的轉(zhuǎn)動(dòng)速度是一定的。磁頭在硬盤(pán)上讀寫(xiě)數(shù)據(jù)是近乎于圓弧的路線(xiàn),而越往外,線(xiàn)速度就越快。為了保證讀取的準(zhǔn)確性只能減小外道的密度使磁頭讀取數(shù)據(jù)的時(shí)間間隔是相同的。
有待研究:早期的磁盤(pán)每個(gè)磁道上的扇區(qū)數(shù)目是一樣,顯然浪費(fèi)了外圈的容量,后來(lái)為了增大磁盤(pán)容量采用了新技術(shù),也就是說(shuō)越往外每磁道扇區(qū)數(shù)目越多。
字符設(shè)備:按照字符流的方式被有序訪問(wèn),不能隨機(jī)存取,如鍵盤(pán)、串口打印機(jī)、磁帶。
塊設(shè)備:能夠隨機(jī)(不需要按順序)訪問(wèn)固定大小數(shù)據(jù)片(chunks),采用塊緩沖技術(shù),如硬盤(pán)、軟盤(pán)、光驅(qū)。
裸設(shè)備:是一種沒(méi)有經(jīng)過(guò)格式化,不被Unix通過(guò)文件系統(tǒng)來(lái)讀取的特殊字符設(shè)備。
現(xiàn)在問(wèn)題來(lái)了,Oracle在使用裸設(shè)備時(shí)(如ASM、甚或表空間直接建在裸設(shè)備上),難道還是順序存取?顯然不符合事實(shí)。
其實(shí),說(shuō)裸設(shè)備是字符設(shè)備,只是從操作系統(tǒng)的角度來(lái)說(shuō)的;從使用裸設(shè)備的應(yīng)用程序(如Oracle)的角度,還是塊設(shè)備,Oracle會(huì)去對(duì)磁盤(pán)進(jìn)行分塊管理。
邏輯卷是邏輯概念,可以包含多塊物理硬盤(pán),實(shí)現(xiàn)了存儲(chǔ)跨盤(pán)功能,同時(shí)提供了數(shù)據(jù)復(fù)制機(jī)制,提供了數(shù)據(jù)安全保護(hù)機(jī)制。
--------------
裸設(shè)備適用于每次改動(dòng)數(shù)據(jù)較小、需大量并發(fā)交易,OLTP;
對(duì)于大規(guī)模順序讀寫(xiě),裸設(shè)備性能是最差的,所以對(duì)OLAP,應(yīng)使用塊設(shè)備或卷。
--創(chuàng)建一個(gè)分區(qū)表
create table scott.testpart
(
?? ?TEXTDATE?? VARCHAR2(8)
)
partition by range ( TEXTDATE )
(
?? ? partition p1 values less than ('20090201'),
??? ?partition
"p2" values less than ('20090301'),
--注意這里的雙引號(hào)?? ? partition pm values less than (MAXVALUE) ?
)
--插入一些數(shù)據(jù)(順便實(shí)踐一下雙層循環(huán))DECLARE
?? ?i int:=1;
?? ?j int:=1;
BEGIN
? ??? ?WHILE i<=3 LOOP
?? ??? ???? WHILE j<=3 LOOP
?? ??? ??? ???? insert into scott.testpart values (2009*10000+i*100+j);
???? ??? ??? ?? j:=j+1;
?? ??? ???? END LOOP;???? ??? ?
?? ???? i:=i+1;?? ?
?? ???? j:=1;
--注意要重置j,否則就回不到j(luò)循環(huán)里面了?? ???? END LOOP;
END;
--需要先進(jìn)行分析,否則num_rows列將為空analyze table scott.testpart compute statistics;
--查看各個(gè)分區(qū)的情況select table_name, partition_name, num_rows from DBA_TAB_PARTITIONS
where table_owner='SCOTT' and table_name='TESTPART';
TABLE_NAME??????????????? PARTITION_NAME?????????? NUM_ROWS
-------------------------- ------------------------------ ----------
TESTPART?????????????????????? P1?????????????????????????????????? ? ?? ?? ?? 3
TESTPART?????????????????????? PM????????????????????????????????? ? ? ?? ?? 3
TESTPART??????????????????????
p2?????????????????????????????????????? ? ? ? 3
注意p2因?yàn)榧恿艘?hào)仍然是小寫(xiě)(但并不顯示引號(hào),這點(diǎn)比較討厭),沒(méi)加引號(hào)的會(huì)顯示為大寫(xiě)--驗(yàn)證數(shù)據(jù)確實(shí)進(jìn)入了正確的分區(qū)select * from scott.testpart partition(p1);
TEXTDATE
--------
20090101
20090102
20090103
--創(chuàng)建p2時(shí)有引號(hào),使用p2時(shí)也就需要引號(hào)。--特別的,用一些第三方客戶(hù)端創(chuàng)建分區(qū)表時(shí),生成的SQL往往會(huì)自動(dòng)加上引號(hào),而查看DBA_TAB_PARTITIONS時(shí)又看不出來(lái),所以遇到下面的問(wèn)題,可以加個(gè)引號(hào)試試。select * from scott.testpart partition(p2);
ERROR at line 1:
ORA-02149: Specified partition
does not existselect * from scott.testpart partition(
"p2");
TEXTDATE
--------
20090201
20090202
20090203
--其它相關(guān)select * from scott.testpart;
truncate table scott.testpart;
drop table scott.testpart;
股票的面值,是股份公司在所發(fā)行的股票票面上標(biāo)明的票面金額,它以元/股為單位,其作用是用來(lái)表明每一張股票所包含的資本數(shù)額。
在我國(guó)上海和深圳證券交易所流通的股票的面值均為壹元,即每股一元。一般來(lái)說(shuō),股票的發(fā)行價(jià)格都會(huì)高于其面值。當(dāng)股票進(jìn)入流通市場(chǎng)后,股票的面值就與股票的價(jià)格沒(méi)有什么關(guān)系了。股民愛(ài)將股價(jià)炒到多高,它就有多高。
按股東權(quán)利分類(lèi),股票可分為普通股、優(yōu)先股和后配股。
在我國(guó)上交所與深交所上市的股票都是普通股。
股息紅利作為股東的投資收益,是以股份為單位計(jì)算的貨幣金額,如每股多少元。但在上市公司實(shí)施具體分派時(shí),其形式可以有四種:這就是現(xiàn)金股利、財(cái)產(chǎn)股利、負(fù)債股利和股票股利等。
滬深股市的上市公司進(jìn)行利潤(rùn)分配一般只采用股票紅利和現(xiàn)金紅利兩種,即統(tǒng)稱(chēng)所說(shuō)的送紅股和派現(xiàn)金。
當(dāng)上市公司向股東分派股息時(shí),就要對(duì)股票進(jìn)行除息;當(dāng)上市公司向股東送紅股時(shí),就要對(duì)股票進(jìn)行除權(quán)。
我國(guó)上市公司中約有一半以上的股份為國(guó)家股,且其股權(quán)代表基本上都是上市公司的經(jīng)營(yíng)管理人員。由于切身利益的影響,經(jīng)營(yíng)管理人員基本上都贊同企業(yè)的發(fā)展與擴(kuò)張,所以我國(guó)上市公司的分紅中,送紅股的現(xiàn)象就非常普遍。
硬鏈接
[oracle@dcm ~]$ ln original.file hard.link
軟鏈接
[oracle@dcm ~]$ ln
-s original.file soft.link
[oracle@dcm ~]$ ls -l
-rw-r--r--
2 oracle oinstall??? 4 Jul 14 17:21 original.file
-rw-r--r--
2 oracle oinstall??? 4 Jul 14 17:21 hard.link
lrwxrwxrwx 1 oracle oinstall?? 13 Jul 14 17:23
soft.link -> original.file
鏈接數(shù)只是和硬鏈接相關(guān)的一個(gè)概念
從鏈接文件可以跟蹤到軟鏈接的指向(無(wú)法反向跟蹤)
---------------
由于inode這種文件系統(tǒng)結(jié)構(gòu)不是雙向的,不能查找一個(gè)inode被reference了多少次。我們只能通過(guò)一些技巧來(lái)跟蹤硬鏈接。
1. 通過(guò)鏈接數(shù),我們可以知道哪個(gè)文件有硬鏈接(大于1)
2. 查找該文件的inode id
[oracle@dcm ~]$ ls -i hard.link
1573158 hard.link
3. 通過(guò)inode id查找文件(如果需要遍歷的目錄很多,速度自然可想而知)
[oracle@dcm ~]$ find -inum 1573158
./hard.link
./original.file
4. 硬鏈接本質(zhì)上是多個(gè)dentry指向同一個(gè)inode,所以并沒(méi)有主從之分,每個(gè)dentry都是平等的。
--修改后重新啟動(dòng)數(shù)據(jù)庫(kù),永久生效
SQL> alter system set nls_date_format='yyyymmdd';
ERROR at line 1:
--不能是memory scope(默認(rèn)是both,所以也不行)ORA-02096: specified initialization parameter is not modifiable with this option
SQL> alter system set nls_date_format='yyyymmdd' scope=spfile;
System altered.
SQL> show parameter nls_date_format?
--這個(gè)時(shí)候還沒(méi)生效NAME???????????????????????????????? TYPE??????? VALUE
------------------------------------ ----------- ------------------------------
nls_date_format????????????????????? string
--重啟數(shù)據(jù)庫(kù)后SQL> show parameter nls_date_format
NAME???????????????????????????????? TYPE??????? VALUE
------------------------------------ ----------- ------------------------------
nls_date_format????????????????????? string????? yyyymmdd
SQL> select sysdate from dual;
SYSDATE
--------
20090627
--只對(duì)當(dāng)前session有效,重登錄一次SQLPLUS,效果就消失了SQL> alter session set nls_date_format='yyyy-mm-dd';??
--這個(gè)格式也很常用 yyyy-mm-dd hh:mi:ssSession altered.?
--同時(shí)會(huì)覆蓋初始化參數(shù)里的設(shè)置SQL> select sysdate from dual;
SYSDATE
----------
2009-06-27
Oracle所有對(duì)象的相關(guān)信息都可以通過(guò)
靜態(tài)數(shù)據(jù)字典來(lái)查找,但數(shù)據(jù)字典實(shí)在太多,也記不清名字。
因?yàn)閿?shù)據(jù)字典都是以
DBA_開(kāi)頭的
視圖,所以可以想辦法先把它們列出來(lái)。
btw,DBA>ALL>User以下兩句結(jié)果上是等效的
select object_name from dba_objects where object_name like 'DBA\_%' escape '\' and object_type='VIEW';
select view_name from dba_views where view_name like 'DBA\_%' escape '\';
例子:
我想查看數(shù)據(jù)文件的相關(guān)信息,但是從DBA_DATA_FILES里,并沒(méi)有看見(jiàn)Temp表空間的數(shù)據(jù)文件的信息。
于是可以嘗試如下搜索:
SQL> select view_name from dba_views where view_name like 'DBA\_%
TEMP%' escape '\';
VIEW_NAME
------------------------------
DBA_ADVISOR_SQLW_TEMPLATES
DBA_ADVISOR_TEMPLATES
DBA_HIST_BASELINE_TEMPLATE
DBA_LOB_TEMPLATES
DBA_REPCAT_REFRESH_TEMPLATES
DBA_SUBPARTITION_TEMPLATES
DBA_TEMPLATE_REFGROUPS
DBA_TEMPLATE_TARGETS
DBA_TEMP_FILES???
--找到嫌疑犯,進(jìn)去一看,果然記錄的是關(guān)于Temp表空間的數(shù)據(jù)文件的信息DBA_TEMP_FREE_SPACE

列一些常用的在這吧
有趣的時(shí),絕大多數(shù)數(shù)據(jù)字典都是復(fù)數(shù)單詞,一般從單詞上也都能猜出該視圖的作用:
dba_users?????數(shù)據(jù)庫(kù)用戶(hù)信息
dba_segments??表段信息
dba_extents????數(shù)據(jù)區(qū)信息
dba_objects????數(shù)據(jù)庫(kù)對(duì)象信息
dba_tablespaces???數(shù)據(jù)庫(kù)表空間信息
dba_data_files????數(shù)據(jù)文件設(shè)置信息
dba_temp_files???臨時(shí)數(shù)據(jù)文件信息
dba_rollback_segs???回滾段信息
dba_ts_quotas???用戶(hù)表空間配額信息
dba_free_space??數(shù)據(jù)庫(kù)空閑空間信息
dba_profiles???數(shù)據(jù)庫(kù)用戶(hù)資源限制信息
dba_sys_privs???用戶(hù)的系統(tǒng)權(quán)限信息
dba_tab_privs??用戶(hù)具有的對(duì)象權(quán)限信息
dba_col_privs??用戶(hù)具有的列對(duì)象權(quán)限信息
dba_role_privs??用戶(hù)具有的角色信息
dba_audit_trail??審計(jì)跟蹤記錄信息
dba_stmt_audit_opts??審計(jì)設(shè)置信息
dba_audit_object???對(duì)象審計(jì)結(jié)果信息
dba_audit_session??會(huì)話(huà)審計(jì)結(jié)果信息
dba_indexes??用戶(hù)模式的索引信息
這兩個(gè)命令都是用來(lái)更改一些數(shù)據(jù)庫(kù)配置的,所以經(jīng)常容易混淆,如:
>alter database drop logfile group 1;
>alter system switch logfile;
>alter system kill session 'sid,serial#';
為了方便記憶,歸納如下:
alter database (改變數(shù)據(jù)庫(kù)--database)
和物理文件直接相關(guān)的操作
alter system (改變實(shí)例--instance)
不直接牽涉到磁盤(pán)文件的操作當(dāng)然,這只是為了方便記憶,只滿(mǎn)足大部分的情況,并不是所有的命令都能套到這個(gè)框框里,最終還是用熟了就記住哪個(gè)是哪個(gè)了。---外傳---
oracle server=Instance (memory structure) + Database (disk file) + U/S Process
?? Instance=SGA + Background Process
?? Database=control file + data file + log file
?? U/S Process= User Process + Server Process + PGA
《道路交通安全法實(shí)施條例》第四十九條規(guī)定,機(jī)動(dòng)車(chē)在有禁止掉頭或者禁止左轉(zhuǎn)彎標(biāo)志、標(biāo)線(xiàn)的地點(diǎn)以及在鐵路道口、人行橫道、橋梁、急彎、陡坡、隧道或者容易發(fā)生危險(xiǎn)的路段,不得掉頭;機(jī)動(dòng)車(chē)在沒(méi)有禁止掉頭或者沒(méi)有禁止左轉(zhuǎn)彎標(biāo)志、標(biāo)線(xiàn)的地點(diǎn)可以掉頭,但不得妨礙正常行駛的其他車(chē)輛和行人的通行。在允許掉頭的地點(diǎn)設(shè)有掉頭專(zhuān)用信號(hào)燈的,應(yīng)當(dāng)在綠燈期間掉頭;未設(shè)有掉頭信號(hào)燈的,但有相應(yīng)的標(biāo)志標(biāo)明在紅燈或者綠燈期間掉頭的,應(yīng)當(dāng)按照標(biāo)志的指示掉頭;既無(wú)掉頭專(zhuān)用信號(hào)燈,又無(wú)其他標(biāo)志指示的,掉頭時(shí)可不受信號(hào)燈限制,但掉頭時(shí)不得妨礙正常行駛的車(chē)輛和行人通行。
-----
有下列情形之一的,依法予以處罰:
?? (1)在設(shè)有禁止掉頭(禁止左轉(zhuǎn)彎)標(biāo)志、標(biāo)線(xiàn)的地點(diǎn)掉頭的;??? ?
?? (2)在人行橫道處掉頭的;
?? (3)在非禁止掉頭的地點(diǎn)掉頭與正常行駛的車(chē)輛、行人發(fā)生交通事故的,按掉頭時(shí)妨礙正常行駛的車(chē)輛通行或掉頭時(shí)妨礙正常行駛的行人通行的行為予以處罰。
?? (4)沒(méi)有從左側(cè)第一條車(chē)道(設(shè)置專(zhuān)用掉頭車(chē)道的除外)掉頭的,按掉頭時(shí)未按規(guī)定駛?cè)胱钭髠?cè)車(chē)道的行為進(jìn)行處罰。
-----
(一)下列情形,不屬于違法行為:
??? (1)在沒(méi)有禁止掉頭(禁止左轉(zhuǎn)彎)標(biāo)志、標(biāo)線(xiàn)的地點(diǎn)掉頭的;
??? (2)
在沒(méi)有禁止掉頭(禁止左轉(zhuǎn)彎)標(biāo)志、標(biāo)線(xiàn)的路口,紅燈期間或綠燈期間掉頭的;??? (3)
在黃色網(wǎng)格線(xiàn)內(nèi)掉頭的。(二)有下列情形之一的,依法予以處罰:
?? (1)在設(shè)有禁止掉頭(禁止左轉(zhuǎn)彎)標(biāo)志、標(biāo)線(xiàn)的地點(diǎn)掉頭的;??? ?
?? (2)
在人行橫道處掉頭的;
?? (3)在非禁止掉頭的地點(diǎn)掉頭與正常行駛的車(chē)輛、行人發(fā)生交通事故的,按掉頭時(shí)妨礙正常行駛的車(chē)輛通行或掉頭時(shí)妨礙正常行駛的行人通行的行為予以處罰。
?? (4)
沒(méi)有從左側(cè)第一條車(chē)道(設(shè)置專(zhuān)用掉頭車(chē)道的除外)掉頭的,按掉頭時(shí)未按規(guī)定駛?cè)胱钭髠?cè)車(chē)道的行為進(jìn)行處罰。
運(yùn)行該Sub,所有單元格的字母都會(huì)變成大寫(xiě)的
Sub
?cap()
Dim
?cell?
As
?Range
For
?
Each
?cell?In?UsedRange
????cell.Value?
=
?
UCase
$(cell.Value)
Next
End?Sub
給定一段時(shí)間,計(jì)算出什么時(shí)候到期
Sub
?deadline()
????
Dim
?deadtime?
As
?
Date
????deadtime?
=
?
DateAdd
(
"
d
"
,?Cells(
2
,?
2
),?
Now
)???????
'
day
????deadtime?
=
?
DateAdd
(
"
h
"
,?Cells(
2
,?
3
),?deadtime)??
'
hour
????deadtime?
=
?
DateAdd
(
"
n
"
,?Cells(
2
,?
4
),?deadtime)??
'
minute
????ActiveCell.Value?
=
?deadtime
End?Sub
'
選中右移
ActiveCell.Value?
=
?
123
Cells(ActiveCell.Row,?ActiveCell.Column?
+
?
1
).Select
ActiveCell.Value?
=
?
456
登錄RMAN
[oracle@dcm ~]$ rman target /
Recovery Manager: Release 11.1.0.6.0 - Production on Wed May 13 13:25:30 2009
Copyright (c) 1982, 2007, Oracle.? All rights reserved.
connected to target database: O11G (DBID=140043054)
? 或[oracle@dcm ~]$ rmanRecovery Manager: Release 11.1.0.6.0 - Production on Thu Jun 18 13:28:07 2009
Copyright (c) 1982, 2007, Oracle.? All rights reserved.
RMAN> connect target /connected to target database: O11G (DBID=140043054)
因?yàn)閿?shù)據(jù)庫(kù)是Open的,且又是非歸檔模式,所以無(wú)法進(jìn)行在線(xiàn)全備份RMAN> backup database;ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
關(guān)了,整成mount狀態(tài)RMAN> shutdowndatabase closed
database dismounted
Oracle instance shut down
RMAN> startup mountconnected to target database (not started)
Oracle instance started
database mounted
開(kāi)始數(shù)據(jù)庫(kù)全備份RMAN> backup database;Starting backup at 13-MAY-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=154 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/o11g/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/o11g/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/o11g/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/o11g/undotbs01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/o11g/testspace2.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/o11g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-MAY-09
channel ORA_DISK_1: finished piece 1 at 13-MAY-09
piece handle=/u01/app/oracle/flash_recovery_area/O11G/backupset/2009_05_13/o1_mf_nnndf_TAG20090513T153229_50nxwnqz_.bkp tag=TAG20090513T153229 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:35
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/o11g/testspace.dbf
channel ORA_DISK_1: starting piece 1 at 13-MAY-09
channel ORA_DISK_1: finished piece 1 at 13-MAY-09
piece handle=/u01/app/oracle/flash_recovery_area/O11G/backupset/2009_05_13
/o1_mf_nnndf_TAG20090513T153229_50nxzv00_.bkp tag=TAG20090513T153229 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 13-MAY-09
Starting Control File and SPFILE Autobackup at 13-MAY-09
piece handle=
/home/oracle/myo11g/autobackup/c-140043054-20090513-00 comment=NONE
Finished Control File and SPFILE Autobackup at 13-MAY-09
查看備份信息RMAN> list backup of database;List of Backup Sets
===================
BS Key? Type LV Size?????? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1?????? Full??? 1.15G????? DISK??????? 00:01:33???? 13-MAY-09???? ?
??????? BP Key: 1?? Status: AVAILABLE? Compressed: NO? Tag: TAG20090513T153229
??????? Piece Name: /u01/app/oracle/flash_recovery_area/O11G/backupset/2009_05_13/o1_mf_nnndf_TAG20090513T153229_50nxwnqz_.bkp
? List of Datafiles in backup set 1
? File LV Type Ckp SCN??? Ckp Time? Name
? ---- -- ---- ---------- --------- ----
? 1?????? Full 1565621??? 13-MAY-09 /u01/app/oracle/oradata/o11g/system01.dbf
? 2?????? Full 1565621??? 13-MAY-09 /u01/app/oracle/oradata/o11g/sysaux01.dbf
? 3?????? Full 1565621??? 13-MAY-09 /u01/app/oracle/oradata/o11g/undotbs01.dbf
? 4?????? Full 1565621??? 13-MAY-09 /u01/app/oracle/oradata/o11g/users01.dbf
? 5?????? Full 1565621??? 13-MAY-09 /u01/app/oracle/oradata/o11g/example01.dbf
? 7?????? Full 1565621??? 13-MAY-09 /u01/app/oracle/oradata/o11g/testspace2.dbf
BS Key? Type LV Size?????? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2?????? Full??? 252.00K??? DISK??????? 00:00:07???? 13-MAY-09???? ?
??????? BP Key: 2?? Status: AVAILABLE? Compressed: NO? Tag: TAG20090513T153229
??????? Piece Name: /u01/app/oracle/flash_recovery_area/O11G/backupset/2009_05_13/o1_mf_nnndf_TAG20090513T153229_50nxzv00_.bkp
? List of Datafiles in backup set 2
? File LV Type Ckp SCN??? Ckp Time? Name
? ---- -- ---- ---------- --------- ----
? 6?????? Full 1565621??? 13-MAY-09 /u01/app/oracle/oradata/o11g/testspace.dbf
RMAN> list backup of controlfile;List of Backup Sets
===================
BS Key? Type LV Size?????? Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3?????? Full??? 9.36M????? DISK??????? 00:00:08???? 13-MAY-09?????
??????? BP Key: 6?? Status: AVAILABLE? Compressed: NO? Tag: TAG20090513T161909
??????? Piece Name: /home/oracle/myo11g/autobackup/c-140043054-20090513-01
? Control File Included: Ckp SCN: 1568079????? Ckp time: 13-MAY-09
刪除指定(BS Key)的備份集RMAN> delete backupset 1;using channel ORA_DISK_1
List of Backup Pieces
BP Key? BS Key? Pc# Cp# Status????? Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
1?????? 1?????? 1?? 1?? AVAILABLE?? DISK??????? /u01/app/oracle/flash_recovery_area/O11G/backupset/2009_05_13/o1_mf_nnndf_TAG20090513T153229_50nxwnqz_.bkp
Do you really want to delete the above objects (enter YES or NO)?
YESdeleted backup piece
backup piece handle=/u01/app/oracle/flash_recovery_area/O11G/backupset/2009_05_13/o1_mf_nnndf_TAG20090513T153229_50nxwnqz_.bkp RECID=1 STAMP=686763156
Deleted 1 objects
刪除所有備份集RMAN> delete backup;using channel ORA_DISK_1
List of Backup Pieces
BP Key? BS Key? Pc# Cp# Status????? Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
2?????? 2?????? 1?? 1?? AVAILABLE?? DISK??????? /u01/app/oracle/flash_recovery_area/O11G/backupset/2009_05_13/o1_mf_nnndf_TAG20090513T153229_50nxzv00_.bkp
3?????? 3?????? 1?? 1?? AVAILABLE?? DISK??????? /home/oracle/myo11g/autobackup/c-140043054-20090513-00
Do you really want to delete the above objects (enter YES or NO)? YES
deleted backup piece
backup piece handle=/u01/app/oracle/flash_recovery_area/O11G/backupset/2009_05_13/o1_mf_nnndf_TAG20090513T153229_50nxzv00_.bkp RECID=2 STAMP=686763258
deleted backup piece
backup piece handle=/home/oracle/myo11g/autobackup/c-140043054-20090513-00 RECID=3 STAMP=686763268
Deleted 2 objects
01555
ORA-01555: snapshot too old?? ?回滾段不夠用了
可以采取的措施有:
1、應(yīng)用程序盡量避免巨表的漫長(zhǎng)查詢(xún)操作,改傳統(tǒng)的cursor游標(biāo)為bulk collect;
2、盡量程序中不要使用大事務(wù)量的增刪改操作,同時(shí)記得及時(shí)commit;
3、加大undo表空間和加大undo的retention。
10046
Event 10046是oracle用于系統(tǒng)性能分析時(shí)的一個(gè)最重要的事件。
Ora
s
le
74億美元呀,現(xiàn)在Oracle可以和18摸全面抗衡了!
簡(jiǎn)直就成了IT屆的 GE vs 西門(mén)子!

----收購(gòu)后的格局----
航母級(jí):IBM? vs? Oracle+SUN
軟件:Microsoft,SAP,RedHat,Sybase(小賽的級(jí)別是不夠放在這的,我覺(jué)得它最終也會(huì)走上被收購(gòu)的道路)
硬件:HP,Dell,F(xiàn)ujitsu
----預(yù)測(cè)----
1. MySQL是生是死?
Oracle是當(dāng)今企業(yè)級(jí)數(shù)據(jù)庫(kù)的老大,MySQL是當(dāng)今互聯(lián)網(wǎng)應(yīng)用的老大。
如果小O把小My干掉,并不代表小My的那部分市場(chǎng)會(huì)成為小O的;相反,如果小O能好好照顧小My,那簡(jiǎn)直就無(wú)敵了。
個(gè)人預(yù)測(cè):75分,只要小O能夠保持一顆開(kāi)放的心,小My應(yīng)該能有很好的發(fā)展。
2. Solaris是生是死?
小O一直致力于發(fā)展Linux技術(shù)(比如他和小紅合作搞的Unbreakable Linux),是把Solaris拿來(lái)當(dāng)補(bǔ)充,還是干掉?
個(gè)人預(yù)測(cè):60分,不會(huì)有太大發(fā)展,保持現(xiàn)狀。
3. Java的發(fā)展方向?
Oracle在很多方面都很需要Java,這是好的一面。
但是Java作為一門(mén)技術(shù),而不是一個(gè)產(chǎn)品,需要有一個(gè)中立的代表,SUN以前的態(tài)度還是不錯(cuò)的。但小O和小I顯然是誓不兩立的,會(huì)不會(huì)導(dǎo)致Java世界的分裂?
個(gè)人預(yù)測(cè):70分,這個(gè)可能最難預(yù)測(cè),實(shí)在不希望看到不好的結(jié)果。
4. 硬件部分
這是小O沒(méi)有的,但是不排除小O把它剝離賣(mài)出去。但我又覺(jué)得這種可能性很小,因?yàn)樾最不缺的就是錢(qián),而且這是小O去和小I叫板的一大資本。
個(gè)人預(yù)測(cè):80分,以后Oracle也可以玩total solution的游戲了。
----關(guān)系----
? 和IBM,這回真的成為死死對(duì)頭了
? 和HP、Dell,選什么產(chǎn)品還是由市場(chǎng)決定的,小O總不能強(qiáng)買(mǎi)強(qiáng)賣(mài)SUN的服務(wù)器吧,還好吧
? 和RedHat,小O和小紅正在一起搞過(guò)Unbreakable Linux,我覺(jué)得小O會(huì)繼續(xù)搞下去
? 和Sybase,這回搞得三大主流操作系統(tǒng)(Windows、AIX、Solaris)都有自己的數(shù)據(jù)庫(kù)了,Sybase的數(shù)據(jù)庫(kù)將越來(lái)越難賣(mài)了
? 和SAP,Microsoft,跟這次收購(gòu)沒(méi)太大關(guān)系,但震撼一定不小
--最多同時(shí)運(yùn)行的JOB個(gè)數(shù);如果太小,JOB就排隊(duì)等待;如果為0,就沒(méi)有JOB會(huì)被執(zhí)行。
SQL> show parameter job_queue_processes
NAME??????????????????????????????????????? TYPE????????? VALUE
--------------------------???????? ----------??? -------------
job_queue_processes???????? integer ?? ????? 10
--一個(gè)什么也不做的SP
CREATE OR REPLACE PROCEDURE mytest
IS
BEGIN
?? ?NULL;
END;
--一個(gè)往表里寫(xiě)數(shù)據(jù)的SPCREATE OR REPLACE PROCEDURE mytest
IS
BEGIN
?? ?insert into test_table values(...);
END;
--定時(shí)調(diào)用SP,10秒(86400秒=1天)SQL> VARIABLE job_id NUMBER;
SQL> BEGIN
??????????
-- :job_id中的冒號(hào)表示冒號(hào)后面的是變量,類(lèi)似SQL Server的@?????????? DBMS_JOB.SUBMIT(:job_id, 'mytest;', sysdate, 'sysdate + 10 / 86400') ;
?????????? COMMIT;?
--記得一定要commit哦?????????? END;
--查看剛才生成的Job IDSQL> set serveroutput on
SQL> execute dbms_output.put_line(:job_id)?
--這里倒是不需要commit,直接execute就好了318--查看所有Job?select * from user_jobs;
--刪除JobSQL> BEGIN
?????????? DBMS_JOB.REMOVE(123); --123是Job ID
?????????? COMMIT;
?????????? END;
如果Job由于某種原因未能成功運(yùn)行,Oracle將重試16次,之后如果還未能成功運(yùn)行,將被標(biāo)記為Broken。
http://www.aygfsteel.com/Jcat/archive/2009/12/17/306315.html
從10g開(kāi)始,DBMS_SCHEDULER 逐步會(huì)替換掉 DBMS_JOB
DBMS_JOB has been around forever, and now it is deprecated. Although DBMS_JOB still exists in 10g and 11g, but only for backward compatibility. No new features are being added to dbms_job and you will likely quickly run into its limitations. Oracle recommends the use of DBMS_SCHEDULER in releases 10g and up. DBMS_SCHEDULER is a much more robust package and fully-featured than DBMS_JOB. To use the DBMS_SCHEDULER package a user must be granted the CREATE JOB privilege.
After replace DBMS_JOB with DBMS_SCHEDULER for all jobs successful, the job_queue_processes parameter can now be set to zero.
SQL> alter system set job_queue_processes=0;
登錄? shell> mysql -u用戶(hù)名 -p密碼
查看數(shù)據(jù)庫(kù)? mysql> show databases;
至少會(huì)顯示出兩個(gè)數(shù)據(jù)庫(kù)mysql和test,這是系統(tǒng)自建的,供大家練習(xí)用。使用數(shù)據(jù)庫(kù)? mysql> use 數(shù)據(jù)庫(kù)名
查看表? mysql> show tables;
查看表結(jié)構(gòu)? mysql> desc 表名;
備份數(shù)據(jù)庫(kù)? shell> mysqldump -uroot -p密碼 數(shù)據(jù)庫(kù)名 > 備份的文件路徑
SunOS是Sun的操作系統(tǒng)最初叫法,SunOS主要是基于BSDUnix版本;
SunOS
5.0開(kāi)始,SUN的操作系統(tǒng)開(kāi)發(fā)開(kāi)始轉(zhuǎn)向System V Release 4,并且有了新的名字叫做
Solaris2.0;
Solaris
2.6以后,SUN刪除了版本號(hào)中的"2,因此,SunOS 5.10就叫做
Solaris 10。
最后"SunOS"這個(gè)詞被用做專(zhuān)指Solaris操作系統(tǒng)的內(nèi)核;而Solaris被認(rèn)為是由SunOS,圖形化的桌面計(jì)算環(huán)境,
以及它網(wǎng)絡(luò)增強(qiáng)部分組成。
?
---Solaris與Sunos的版本轉(zhuǎn)換---
Solaris 10 = SunOS 5.10
Solaris 9 = SunOS 5.9
Solaris 8 = SunOS 5.8
Solaris 7 = SunOS 5.7Solaris 2.6 = SunOS 5.6
Solaris 2.5 = Sunos 5.5
------------------
Solaris也有分服務(wù)器版和個(gè)人版,它們分別是:
??
服務(wù)器版:sparc
??
個(gè)人版:x86
雖然Solaris在SPARC上擁有強(qiáng)大的處理能力和硬件支持,但是在Intel x86上性能卻未如人意。
為了跟老外聊天,裝了個(gè)Skype。后來(lái)發(fā)現(xiàn)可以用來(lái)打IP電話(huà),超值!
這東西很適合我們這些北漂專(zhuān)門(mén)用來(lái)給家里打長(zhǎng)途:
1. 地點(diǎn)固定,我都是周末的晚上在家往老家打電話(huà),肯定是在電腦前的
2. 因?yàn)镾kype不分本地長(zhǎng)途,用來(lái)打長(zhǎng)途更體現(xiàn)優(yōu)勢(shì)
3. 通話(huà)時(shí)間長(zhǎng),我一般一周打一次,每次30分鐘左右,就更更體現(xiàn)優(yōu)勢(shì)了
不適合打本地電話(huà):
1. 撥打的地點(diǎn)都是不可預(yù)期的,總不能要電話(huà)了,還得把電腦打開(kāi)、上網(wǎng)
2. 上班的時(shí)候倒是都在電腦前,但可以用公司的座機(jī)嘛,免費(fèi)的
3. 省錢(qián)的優(yōu)勢(shì)不明顯:移動(dòng)2.5;固話(huà)2.2角(管前三分鐘),之后1.1
Sample: 每月往家打100分鐘(一周一次,每次25分鐘)
?? Skype=100*0.075+3=10.5元
?? 手機(jī)9點(diǎn)前=100*0.35=35元
?? 手機(jī)9點(diǎn)后=100*0.22=22元
基金的買(mǎi)賣(mài)時(shí)間和大盤(pán)一樣,但是網(wǎng)上一般可以隨時(shí)下單;如果是閉盤(pán)時(shí)間下的單,就順延到下一個(gè)開(kāi)盤(pán)日購(gòu)買(mǎi)。
今天看到的基金凈值,其實(shí)是昨天的值。
今天購(gòu)買(mǎi)的基金,其凈值明天才能看見(jiàn)。
下午3點(diǎn)以前購(gòu)買(mǎi)基金,算作今天購(gòu)買(mǎi);3點(diǎn)以后,算作明天購(gòu)買(mǎi),即凈值要在后天才能看見(jiàn)。
基金管理費(fèi):一般為1%左右,每天根據(jù)資產(chǎn)總額提取,凈值是已經(jīng)提取了管理費(fèi)和托管費(fèi)后的價(jià)格。
---------------------------
基民首先要弄清楚“認(rèn)購(gòu)”與“申購(gòu)”的區(qū)別。
1. 認(rèn)購(gòu)是針對(duì)新基金而言的,這個(gè)時(shí)候所認(rèn)購(gòu)的基金并不產(chǎn)生份額凈值,成交價(jià)以1元面值為基準(zhǔn)。
2. 申購(gòu)則指在基金成立后,投資者申請(qǐng)購(gòu)買(mǎi)基金份額的行為。
無(wú)論是認(rèn)購(gòu)還是申購(gòu),交易時(shí)間內(nèi)投資者可以提交認(rèn)/申購(gòu)申請(qǐng)。
投資者只有在交易日下午3點(diǎn)收盤(pán)之前提交申購(gòu)請(qǐng)求才能在當(dāng)日生效,并可能成功交易。
一般來(lái)說(shuō),投資者在份額發(fā)售期內(nèi)已經(jīng)正式受理的認(rèn)購(gòu)申請(qǐng)不得撤銷(xiāo)。
對(duì)于申購(gòu)申請(qǐng),投資者只有在當(dāng)日 15:00前提交撤銷(xiāo)申請(qǐng),才能予以撤銷(xiāo)。
在基金申購(gòu)的過(guò)程中,投資者面臨著一個(gè)“未知成交價(jià)”的交易風(fēng)險(xiǎn),這是因?yàn)樯曩?gòu)價(jià)格以當(dāng)日的基金份額凈值為基準(zhǔn)進(jìn)行計(jì)算,而成交當(dāng)日的基金份額凈值只能在下午3點(diǎn)收盤(pán)之后誕生,這個(gè)凈值一般會(huì)在下一個(gè)交易日開(kāi)始之前公告。
------------------------------
收購(gòu)費(fèi)率是有折扣的(根據(jù)不同的銀行),如易方達(dá)前端申購(gòu)費(fèi)率是0.8%,但是如果用廣發(fā)卡費(fèi)率是0.3%,1w元能省50元呢。
"優(yōu)惠費(fèi)率不按金額分檔,持有廣東發(fā)展銀行理財(cái)通卡的個(gè)人投資者的優(yōu)惠認(rèn)購(gòu)費(fèi)率或申購(gòu)費(fèi)率統(tǒng)一為0.3%。"-- From 易方達(dá)
Habit 1:
Be ProactiveChange starts from within, and highly effective people make the decision to improve their lives through the things that they can influence rather than by simply reacting to external forces.
Habit 2:
Begin with the End in MindDevelop a principle-centered personal mission statement. Extend the mission statement into long-term goals based on personal principles.
Habit 3:
Put First Things FirstSpend time doing what fits into your personal mission, observing the proper balance between production and building production capacity. Identify the key roles that you take on in life, and make time for each of them.
Habit 4:
Think Win/WinSeek agreements and relationships that are mutually beneficial. In cases where a "win/win" deal cannot be achieved, accept the fact that agreeing to make "no deal" may be the best alternative. In developing an organizational culture, be sure to reward win/win behavior among employees and avoid inadvertantly rewarding win/lose behavior.
Habit 5:
Seek First to Understand, Then to Be UnderstoodFirst seek to understand the other person, and only then try to be understood. Stephen Covey presents this habit as the most important principle of interpersonal relations. Effective listening is not simply echoing what the other person has said through the lens of one's own experience. Rather, it is putting oneself in the perspective of the other person, listening empathically for both feeling and meaning.
Habit 6:
SynergizeThrough trustful communication, find ways to leverage individual differences to create a whole that is greater than the sum of the parts. Through mutual trust and understanding, one often can solve conflicts and find a better solution than would have been obtained through either person's own solution.
Habit 7:
Sharpen the SawTake time out from production to build production capacity through personal renewal of the physical, mental, social/emotional, and spiritual dimensions. Maintain a balance among these dimensions.
?
很多時(shí)候,在我們進(jìn)行數(shù)據(jù)庫(kù)操作時(shí),比如drop user,drop table等,經(jīng)常會(huì)遇到這樣的錯(cuò)誤:
ORA-00604: error occurred at recursive SQL level 1 .
關(guān)于Recursive SQL錯(cuò)誤:
我們知道,當(dāng)我們發(fā)出一條簡(jiǎn)單的命令以后,Oracle數(shù)據(jù)庫(kù)要在后臺(tái)解析這條命令,并轉(zhuǎn)換為Oracle數(shù)據(jù)庫(kù)的一系列后臺(tái)操作,這些后臺(tái)操作統(tǒng)稱(chēng)為遞歸SQL。
比如create table這樣一條簡(jiǎn)單的DDL命令,Oracle數(shù)據(jù)庫(kù)在后臺(tái),實(shí)際上要把這個(gè)命令轉(zhuǎn)換為對(duì)于obj$,tab$,col$等底層表的插入操作。Oracle所作的工作可能比我們有時(shí)候想的要復(fù)雜的多.。
所以對(duì)于這樣的提示,很多時(shí)候是沒(méi)有絲毫用處的。
這時(shí),我們需要更詳細(xì)的信息,sql_trace就是一個(gè)好辦法。
sql_trace實(shí)際上就是Oracle內(nèi)部事件10046的第一個(gè)級(jí)別,即level=1。通過(guò)
event 10046, 我們可以得到詳細(xì)的數(shù)據(jù)庫(kù)會(huì)話(huà)的信息,每個(gè)會(huì)話(huà)究竟在干什么,在等什么。通過(guò)對(duì)這個(gè)事件的學(xué)習(xí),我們可以深入的理解和調(diào)整Oracle。
結(jié)合eygle的文章整理的,SQL Trace更詳細(xì)的用法請(qǐng)見(jiàn)原文。----------
Event 10046是oracle用于系統(tǒng)性能分析時(shí)的一個(gè)最重要的事件。當(dāng)激活這個(gè)事件后,將通知oracle kernel追蹤會(huì)話(huà)的相關(guān)即時(shí)信息,并寫(xiě)入到相應(yīng)trace文件中。這些有用的信息主要包括sql是如何進(jìn)行解析,綁定變量的使用情況,話(huà)中發(fā)生的等待事件等。
Trace文件將會(huì)存放在
user_dump_dest 所指向的目錄,如,C:\ent\oracle\admin\o10g01\udump
Event 10046可分成不同的級(jí)別(level),分別追蹤記錄不同程度的有用信息。對(duì)于這些不同的級(jí)別,應(yīng)當(dāng)注意的是向下兼容的,即高一級(jí)的trace信息包含低于此級(jí)的所有信息。
??? level 1:跟蹤sql語(yǔ)句,包括解析、執(zhí)行、提取、提交和回滾等。
??? level 4:包括變量的詳細(xì)信息
??? level 8:包括等待事件
??? level 12:包括綁定變量與等待事件
其中,level 1相當(dāng)于打開(kāi)了sql_trace。
在當(dāng)前會(huì)話(huà)啟用event,可以利用alter session + 事件名稱(chēng) + level:
SQL> alter session set event ‘10046 trace name context forever, level 12’;關(guān)閉當(dāng)前會(huì)話(huà)的event:
SQL> alter session set event ‘10046 trace name context off’;這里應(yīng)當(dāng)值得一提的是,TRACE將消耗相當(dāng)?shù)南到y(tǒng)資源,因此我們?cè)谑褂肨RACE的時(shí)候應(yīng)當(dāng)慎重。對(duì)于正式的系統(tǒng),應(yīng)當(dāng)只在必要的時(shí)候進(jìn)行TRACE操作,并且應(yīng)當(dāng)及時(shí)關(guān)閉。
湖人vs雄鹿,第四節(jié)垃圾時(shí)間,孫悅終于替補(bǔ)出場(chǎng)。

上來(lái)就3個(gè)犯規(guī),1個(gè)運(yùn)球失誤,顯得很緊張,身體僵硬。又失誤了,隊(duì)友安慰他。
然后1個(gè)三分的機(jī)會(huì),沒(méi)進(jìn),動(dòng)作很僵硬。
終于有個(gè)中距離的機(jī)會(huì),孫悅投中了,全場(chǎng)鼓掌!
后來(lái)又有一個(gè)反擊的機(jī)會(huì),孫悅籃下打板進(jìn)了,繼續(xù)鼓掌!恭賀菜鳥(niǎo)的第一次NBA亮相!
2008
11-25 XX is a brilliant scientist.
11-26 She used to knit her brows when meeting with a difficult problem.
11-27 The tea bubbled in the pot.
11-28 I budgeted for a daily expenditure of 15 dollars.
11-29 The elephant lowered its huge bulk.
11-30 She bumped her arm against the door.
12-1 He has lost the bunch of keys and cannot unlock the door.
12-2 We collected a bundle of old clothes to be given to them.
12-3 He has found a job in the Washington Bureau of the Associated Press.
12-4 Whenever I have to stand up to make a speech, I get butterflies in my stomach.
12-5 How much does it cost for the first cabin.
12-6 Put all these documents into a filing cabinet.
12-7 The messages have come by cable.
12-8 He has calculated the advantage and disadvantage before making the decision.
12-9 The calendar shows that Christmas will fall on a Monday.
12-10 He announced that he would campaign for the senate.
12-11 The Princeton campus has developed into one of the most attractive school in the USA.
終于還是沒(méi)堅(jiān)持下來(lái),看來(lái)堅(jiān)持不懈做一件很小的事也是很難的。
Oracle Database的大版本號(hào)由兩部分組成:
數(shù)字+字母,數(shù)字自然是大版本號(hào),
字母則是代表了這個(gè)版本的“中心思想”
8i(1998),9i(2001):那時(shí)候正好互聯(lián)網(wǎng)興起,i就代表internet(網(wǎng)絡(luò))10g(2003),11g(2007):現(xiàn)在主推分布式計(jì)算,g就代表grid(網(wǎng)格)另外,還有個(gè)11i,這容易引起混淆,其實(shí)11i是指Oracle EBS(E-Business Suite電子商務(wù)套件)的版本號(hào),其實(shí)就是Oracle ERP。(這好像跟Oracle Database沒(méi)什么必然聯(lián)系,我也不知道這個(gè)i代表什么)
這也說(shuō)明Oracle不等于Oracle Database。平常我們說(shuō)“Oracle”,一般都是指Oracle Database,當(dāng)然這是它最著名的產(chǎn)品;不過(guò),其實(shí)Oracle早就已經(jīng)不是一家數(shù)據(jù)庫(kù)廠商了,而是航母級(jí)廠商,東收西購(gòu),啥都有了。
我見(jiàn)過(guò)這樣的問(wèn)題:“從版本命名來(lái)看8i-9i-10g-11i,是不是意味著grid只是曇花一現(xiàn)?”顯然這就是混淆了Oracle Database和Oracle ERP。----以下是一些參考----
In 1998, Oracle announced Oracle8i, which is sometimes referred to as Version 8.1 of the Oracle8 database. The i was added to denote added functionality supporting Internet deployment in the new version. Oracle9i followed, with Application Server available in 2000 and Database Server in 2001.
Oracle Database 10g was introduced in 2003; the g denotes Oracle's focus on emerging grid deployment models.
Oracle 11i refers to the Oracle ERP Application Suite (often called Oracle E-Business Suite) and really has nothing to do with the database. The latest release (12) will be referred to as 12i. The confusing part is that Oracle used to call its database "i" for "internet" in releases 8 and 9, but now calls the database "g" for "grid". So, to summarize, Oracle 11i refers to the apps and Oracle 11g refers to the database
Groovy
把最常用的東西都設(shè)置成default了,經(jīng)常可以省這省那的(比如括號(hào)、分號(hào)、public等);又加上閉包,初學(xué)的時(shí)候,有些代碼,一眼望去,都分不清是方法、是類(lèi)、還是閉包。
這里先簡(jiǎn)單總結(jié)一下常用的修飾符。
package?jcat.bit.g
/*
修飾符有三類(lèi):
1.?static
2.?作用域:public(默認(rèn)),?private,?protected.
3.?類(lèi)型:def(默認(rèn),動(dòng)態(tài)),?void(無(wú)類(lèi)型,靜態(tài)),?其它常規(guī)靜態(tài)類(lèi)型
*/
class?Test?{
????static?def?a_static_def?=?'a_static_def'
????static?a_static?=?'a_static'
????def?a_def?=?'a_def'
????static?void?main(strs)?{
????????println?a_static_def
????????println?a_static
????????println?t_static_def()
????????println?t_static()
????????new?Test().with?{
????????????println?a_def
????????????println?t_public_def()
????????????println?t_public()
????????????println?t_def()
????????}
????}
????static?def?t_static_def()?{?//?def?=?可以返回任何類(lèi)型,包括void
????????return?"t_static_def"
????}
????static?t_static()?{?//?有其它修飾符可以省略def(默認(rèn)public?+?def)
????????return?"t_static"
????}
????public?def?t_public_def()?{
????????return?"t_public_def"
????}
????public?t_public()?{?//?默認(rèn)def
????????return?"t_public"
????}
????def?t_def()?{?//?至少要有一個(gè)修飾符,所以這個(gè)def不能省略;?且默認(rèn)public
????????return?"t_def"
????}
????static?void?t_static_void()?{
????????//return?"t_static_void"????//?cannot?return?an?object?from?a?method?that?returns?"void"
????}
}
用JDBC操作數(shù)據(jù)庫(kù),對(duì)比一下Java和Groovy。
環(huán)境:SQL Server 2000 (記得打補(bǔ)丁SP4,不然JDBC訪問(wèn)會(huì)報(bào)錯(cuò))
JDBC Driver:msbase.jar,mssqlserver.jar,msutil.jar
Java版
package
?jcat.bit.java;
import
?java.sql.
*
;
public
?
class
?JDBC?{
????
public
?
static
?
void
?main(String[]?args)?
throws
?ClassNotFoundException,?SQLException?{
????????Class.forName(
"
com.microsoft.jdbc.sqlserver.SQLServerDriver
"
);
????????Connection?conn?
=
?DriverManager.getConnection(
????????????????
"
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs
"
,
????????????????
"
sa
"
,?
"***
"
);
????????Statement?stmt?
=
?conn.createStatement();
????????ResultSet?rs?
=
?stmt.executeQuery(
"
select?top?10?*?from?authors
"
);
????????
while
?(rs.next())?{
????????????System.out.println(rs.getString(
2
)
+
"
?
"
+
rs.getString(
3
));??//?數(shù)id
????????}
????????rs.close();
????????stmt.close();
????????conn.close();
????}
}
Groovy版
package?jcat.bit.groovy
import?groovy.sql.Sql
class?JDBC?{
????static?void?main(args)?{
????????Sql?sql?=?Sql.newInstance(
????????????????"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs",
????????????????"sa",?"***",
????????????????"com.microsoft.jdbc.sqlserver.SQLServerDriver")
????????sql.eachRow("select?top?10?*?from?authors")?{row?->
????????????println?row.au_fname?+?"?"?+?row.au_lname????//直接用數(shù)據(jù)庫(kù)的字段名就可以操作結(jié)果集了,不用去數(shù)id
????????}
????}
}
總結(jié)
1. 建立查詢(xún),差別不大,都是JDBC那一套;Groovy不用處理異常
2. 處理查詢(xún)結(jié)果,Groovy因?yàn)橛虚]包,
處理這些迭代問(wèn)題很方便3. Groovy不用關(guān)閉
1. 閉包代表(定義)了一段代碼(操作):光看這一句,其實(shí)方法也能實(shí)現(xiàn)相同的功能呀。
2. 閉包可以作為方法的參數(shù):這才是閉包的特殊之處和真正意義。
下面演示一個(gè)只有閉包能做,方法做不到的例子。
方法的作用是提煉共性,再代之以不同的參數(shù)。即對(duì)不同的“數(shù)據(jù)”進(jìn)行相同的“操作”。從3個(gè)loop可以看出:
????Comm1:相同的數(shù)據(jù)
????Comm2:相同的for循環(huán)
????Diff1:循環(huán)體內(nèi)執(zhí)行的操作不同
Comm1很好搞定,參數(shù)aa就是提煉出的共性
Comm2看似是共性,卻很難提煉,因?yàn)閒or循環(huán)和循環(huán)體內(nèi)的操作實(shí)際是一個(gè)整體;Comm2被Diff1糾纏,3個(gè)loop是完全不同的3組操作,無(wú)法提煉。
比如,如果現(xiàn)在想要按照奇數(shù)循環(huán),只能依次改動(dòng)三個(gè)循環(huán)。?
int
[]?aa?
=
?[
1
,?
2
,?
3
,?
4
,?
5
,?
6
]
//
?loop1
for
?(
int
?i?
=
?
0
;?i?
<
?aa.length;?i
++
)?{ ????println?aa[i] }
//
?loop2
for
?(
int
?i?
=
?
0
;?i?
<
?aa.length;?i
++
)?{ ????print?aa[i] }
//
?loop3
for
?(
int
?i?
=
?
0
;?i?
<
?aa.length;?i
++
)?{ ????print?aa[i]?
+
?
'
?
'
}
|
????????
//
?loop1
for
?(
int
?i?
=
?
0
;?i?
<
?aa.length;?i?
+=
?
2
)?{ ????println?aa[i] }
//
?loop2
for
?(
int
?i?
=
?
0
;?i?
<
?aa.length;?i?
+=
?
2
)?{ ????print?aa[i] }
//
?loop3
for
?(
int
?i?
=
?
0
;?i?
<
?aa.length;?i?
+=
?
2
)?{ ????print?aa[i]?
+
?
'
?
'
}
|
下面我們看看閉包的強(qiáng)大之處,Comm1和Comm2都被很好的封裝在了loop方法里;
Diff1則作為參數(shù)(閉包)傳入loop方法。
static?void?main(String[]?a)?{
????int[]?aa?=?[1,?2,?3,?4,?5,?6]
????loop(aa)?{?println?it }
??? loop(aa)?{?print?it?}???
??? loop(aa)?{?print?it?+?'?'?}
}
|
如果我們想要改變循環(huán)的方式,只需要改一處
static?void?loop(int[]?aa,?Closure?c)?{ ????for?(int?i?=?0;?i?<?aa.length;?i++)?{ ????????c.call(aa[i]) ????} ????println?'?' } | static?void?loop(int[]?aa,?Closure?c)?{ ????for?(int?i?=?0;?i?<?aa.length;?i?+=?2)?{ ????????c.call(aa[i]) ????} ????println?'?' } |
總結(jié),閉包本身并沒(méi)什么難點(diǎn),關(guān)鍵是怎樣合理的設(shè)計(jì)一個(gè)接受Closure類(lèi)型參數(shù)的方法。從GDK的方法也可以看出,大多數(shù)接受閉包的方法都是和數(shù)組迭代有關(guān)(也即循環(huán))。
Definition
???
/*
????????1.?變量是用來(lái)裝“數(shù)據(jù)”的,閉包就是用來(lái)裝“操作”的
????????2.?和定義一個(gè)方法一樣,閉包也可以有入?yún)?br />???????
*/
????????Closure?p?
=
?{x?
->
????????????print?x?
+
?
'
?
'
????????}
????????[
1
,?
2
,?
3
].each(p)
????????[
4
,?
5
,?
6
].each({x?
->
?
//
?閉包是可以匿名的
????????????print?x?
+
?
'
?
'
????????})
????????[
7
,?
8
,?
9
].each?{x?
->
?
//
?括號(hào)是可以省略的
????????????print?x?
+
?
'
?
'
????????}
????????[
10
,?
11
,?
12
].each?{?
//
?it是默認(rèn)的參數(shù)名字,所以這里連入?yún)⒌亩x都省了
????????????print?it?
+
?
'
?
'
????????}
Using
package?jcat.bit
class?Test?{
????/*
????1.?閉包是對(duì)象,是Closure類(lèi)的實(shí)例,所以:
????????1)可以在類(lèi)里定義Closure類(lèi)型的屬性
????????2)可以在方法里定義Closure類(lèi)型的變量
????????3)可以定義一個(gè)方法,接收Closure類(lèi)型的參數(shù)
????2.?閉包又有方法特質(zhì),畢竟它裝的是“操作”,甚至可以像調(diào)用方法一樣調(diào)用閉包
?????*/
????static?final?Closure?PRINT_STR?=?{??//?屬性(類(lèi)變量)
????????println?it
????}
????static?void?main(String[]?a)?{
????????/*
????????閉包類(lèi)似Java的內(nèi)部類(lèi),區(qū)別是閉包只有單一的方法可以調(diào)用,但可以有任意的參數(shù),
????????閉包用“{}”括起,“->”前面是參數(shù),后面是處理語(yǔ)句,可以直接調(diào)用,也可以使
????????用call調(diào)用。不管那種調(diào)用,最后groovy編譯器都會(huì)把編譯成對(duì)doCall方法的調(diào)用,
????????這是groovy對(duì)閉包的一個(gè)隱藏方法。
?????????*/
????????PRINT_STR("像方法一樣調(diào)用")
????????PRINT_STR.call("作為Closure的實(shí)例,再調(diào)用相應(yīng)的方法")
????????Closure?printLength?=?{String?s?->??//?局部變量
????????????println?s.length()
????????}
????????printLength("AAA")
????????/*
????????通常,操作是死的,我們能動(dòng)態(tài)代入的是“數(shù)據(jù)”。
????????閉包使得我們可以動(dòng)態(tài)的代入一段“操作”。
????????“閉包是可以用作方法參數(shù)的代碼塊。”
?????????*/
????????closureAsParameter(null,?printLength)
????????closureAsParameter("BBB",?PRINT_STR)
????}
????static?void?closureAsParameter(String?s,?Closure?c)?{
????????if?(s?!=?null)?{
????????????c.call(s)
????????}
????}
}
-----------------------------------------------------------------
附上一個(gè)Java的匿名內(nèi)部類(lèi)的例子,用來(lái)和閉包對(duì)比一下。
package?jcat.bit;
public?class?AnonymousInnerClass?{
????public?static?void?main(String[]?args)?{
????????AbsClass?a?=?new?AbsClass()?{
????????????public?void?foo(String?s)?{
????????????????System.out.println(s);
????????????}
????????};
????????a.foo("ABC");
????????AbsClass?b?=?new?AbsClass()?{
????????????public?void?foo(String?s)?{
????????????????System.out.println(s.length());
????????????}
????????};
????????b.foo("ABC");
????}
}
abstract?class?AbsClass?{
????public?abstract?void?foo(String?s);
}
2008
10-25 Bind the thief's arms with rope.
10-26 Beer tests bitter.
10-27 This pocketknife has two blades.
10-28 If you don't do the work well, you will incur blame.
10-29 My mind was a total blank.
10-30 A blast of wind stirred up the dust.
10-31 The two brothers bled for their country and died happily.
11-1? His manner was a blend of friendliness and respect.
11-2 He gets an awful bloody nose.
11-3 The roses are in bloom.
11-4 The mother often boasts to the neighbors about the success of her children.
11-5 It is very bold of them to venture to travel by sea.
11-6 The bolts are all tight enough.
11-7 The terrorists planted a bomb in the building.
11-8 Comment interests form a bond between us.
11-9 I've booked you in at the hotel.
11-10 China is having a great boom in real estate.
11-11 This new technology will boost the production by 30% next year.
11-12 The criminal escaped over the border.
11-13 I am bored by his tedious talk.
11-14 The football bounced off the goal-post.
11-15 You are bound to succeed.
11-16 The new boundaries of the country were fixed after war.
11-17 The arrow was still held in the bow.
11-18 The brake didn't work.
11-19 He has his own brand of humour.
11-20 He has traveled the length and breadth of China.
11-21 Tom was bred up as a sailor.
11-22 We enjoyed the cool breeze that came from the lake.
11-23 Next Sunday Alvon will become AFu's bride.
11-24 Be brief and to the point.
最近BI的項(xiàng)目不忙,抽空懷念了一下編程技術(shù):
1. <Flex 3> 同事給了我份Flex的教程,把前三章看了一下,有了初步的了解;FlexBuilder也用了一把,不錯(cuò),效果很絢麗。
2. <IDEA 8> 恰逢IDEA 8 EAP (Early Access Preview)發(fā)布,搞了一個(gè)裝上試試。主要試了試對(duì)Flex的支持,感覺(jué)還有待提升。另外IDEA對(duì)內(nèi)存的消耗似乎越來(lái)越多了,沒(méi)做深入體驗(yàn)。
3. <Grails 1.0.3> 拿出了小二去年送我的生日禮物《Grails權(quán)威指南》,翻了翻,Hello World一會(huì)就做好了。打算再進(jìn)一步體驗(yàn)一下。