Jcat
宠辱不惊,闲看庭前花开花落~~
posts - 173,comments - 67,trackbacks - 0
纯好人不用打:白羊

没人防:双子(迷宫)、天平(卡妙的冰箱)、射手(迷宫)

打死:巨蟹(紫龙)、山羊(紫龙自曝)、双鱼(阿瞬)、水瓶(冰河)

没打过,放水:狮子(星矢)、天蝎(冰河)、金牛(星矢)、处女(一辉)


这样看来紫龙是最NB的,一个人干掉2个,而且靠他师傅走后门天平不用打,还用天平的武器救了冰河。

冰河和他师傅干了2仗
冰河那段也挺NB,先是在天平被冻个半死,然后在天蝎被针扎个半死,最后到了水瓶还能把他师傅干掉
冰河和他师傅是最体现实力的一仗,纯实力对扣

合着星矢谁也没杀,就TM来打酱油的。。。
posted @ 2011-10-21 14:29 Jcat 阅读(530) | 评论 (1)编辑 收藏
简单过一遍,详细的以后遇到慢慢研究。
主要的更新在几个方面:
1. OUI的改进
2. Oracle Restart
3. ASM的增强!!!


New Grid Infrastructure Installation Option
 1. 单点包括:ASM、listener和Oracle Restart(监控、管理并自动重启各个组件)
 2. 集群包括:ASM、listener和Clusterware

New Desktop and Server Class Options
 1. Desktop Class:适用于笔记本、台式机
 2. Server Class:适用于服务器(功能上没区别,多一些高级配置选项)

Daylight Savings Time Upgrade of Timestamp with Timezone Data Type
 新的DBMS_DST包,优化对TIMESTAMP WITH TIMEZONE数据的管理

SYSASM Privilege
 管理ASM需要SYSASM权限,旨在分清ASM管理和DB管理

Fixup Scripts and Prerequisite Checks
 安装前检查时,如果遇到不符合要求的配置,OUI会对一些检查项自动生成fixup脚本,用root执行就可以解决相应问题。

New Tool to Configure Custom Installation Options
 OUI不在提供对单个组件的配置功能,如果需要只能用$ORACLE_HOME/bin/chopt命令行进行配置。我想Oracle的趋势就是为了让更多已经成熟的配置自动化,简化使用。

Deinstallation Tool
 OUI不再用来删除oracle软件,请使用$ORACLE_HOME/deinstall

Intelligent Data Placement
 指定ASM磁盘的磁盘范围,旨在将高频访问的数据放在HOT region(比如磁盘的外道)

Oracle Automatic Storage Management Cluster File System (Oracle ACFS)
 为其它文件提供ASM的存储功能

Data Pump Export and Data Pump Import
 Data Pump兼容Export/Import

Use Oracle Restart to Automatically Restart Your Database

 1. 针对单点环境
 2. 自动重启又问题的组件,如:db instance、listener、asm instance

New Method of Installing Oracle Automatic Storage Management
 以前,ASM的安装是伴随着DB的安装;现在是伴随着Software的安装。
 其实,就是把ASM上升到一个软件的高度(以前只是db的一个组件)

SRVCTL Support for Single Instance Database in a Cluster
 SRVCTL统一管理单点(with Restart)和集群数据库(with Clusterware)

Deprecated in Oracle Database 11g Release 2
 不支持裸设备了:要么用文件系统、要么用ASM,说白了,企业环境就必须用ASM
 不支持Oracle Ultra Search(9i的一个什么鸟功能)






















posted @ 2011-06-17 15:35 Jcat 阅读(795) | 评论 (0)编辑 收藏
重装完系统,mysql不需要重装,直接当绿色版使用,还更干净

//启动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
)

//简单使用

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.03 sec)

mysql> use mysql
Database 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
创建数据库
mysql> create database testdb;




posted @ 2011-06-16 01:40 Jcat 阅读(903) | 评论 (1)编辑 收藏
--主键是非分区索引,也可以看作是全局
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;


--主键是分区索引
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;


这个案例也告诉我们,在做DDL时,尽量还是显示的写出属性,一些简易语法会引起不可知的定义。最后都用 get_ddl 再查一下,这才是Oracle真正执行的DDL。
posted @ 2010-09-15 15:26 Jcat 阅读(1261) | 评论 (0)编辑 收藏
列出所有实例
[db2inst1@dcm ~]$ db2ilist
db2inst1

列出当前实例下的所有数据库

[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         =

启动实例
[db2inst1@dcm ~]$ db2start
07/09/2010 14:24:36     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

连接到数据库
[db2inst1@dcm ~]$ db2 connect to sample

   Database Connection Information

 Database server        = DB2/LINUX 9.7.1
 SQL authorization ID   = DB2INST1
 Local database alias   = SAMPLE

执行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.

断开连接(不断开就不能db2stop)
[db2inst1@dcm ~]$ db2 connect reset
DB20000I  The SQL command completed successfully.

关闭实例
[db2inst1@dcm ~]$ db2stop
07/09/2010 14:29:32     0   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.

posted @ 2010-07-09 14:32 Jcat 阅读(237) | 评论 (0)编辑 收藏
最近初探了一下DB2,发现关于“数据库”、“实例”的概念及其关系容易把人弄晕,这里小小总结一下,并把Oracle也拉进来一起整。
另外,发现Oracle和IBM老搞一些理论上就针锋相对的事情,如RAC vs DPF (database partitioning feature),很是有趣。



基本概念还是相同的
数据库软件(下面简称软件:软件本身,一台主机安装一套就可以了。(抛开你故意在一台服务器上安装2遍Oracle/DB2这种不正常思维)

实例:数据库软件启动后的“进程+内存”
软件+实例的关系:一台电脑只需要按照一套QQ(软件),但是我们可以多用户登录(实例)。换到哲学的角度,就是抽象和具体的关系。
数据库(狭义,下面简称:一堆文件(数据文件、控制文件、日志文件、参数文件)
它和软件的区别:软件是厂商卖给你的东西;是你自己的东西(业务、应用)
它和实例的关系:用户需要借助实例(所提供的各种手段)来访问
就相当于是QQ聊天记录

最后:数据库(广义)= 软件 + 实例 + 库
一台服务器(即一套数据库软件)可以建多个实例,多个库,且互不相干


体系结构的不同之处
Oracle  实例和库一一对应
DB2     一个实例可以挂多个库


高级情况(简单提一下,以后再慢慢研究)
Oracle:RAC一个库被多个实例挂
DB2:DPF一个实例多个库
在数据库集群模式设计方面,有Share everything架构和Share nothing架构,前者以ORACLE RAC为代表,IBM DB2 Purescale为挑战者;后者以IBM DB2 DPF为代表。

posted @ 2010-07-08 18:26 Jcat 阅读(403) | 评论 (0)编辑 收藏
行链接:
1. 一条记录的大小大于block size,则产生行链接
2. 容易发生在比较大的行上
3. 因为行链接是由db_block_size不够大引起的,所以对已有的行链接是无法清除的
4. 9i以后,可以对不同的表空间设置不同的db_block_size,可以将一些特殊的宽表放在大block size的表空间

例子:
表空间block size为8k(8192),因为数据块头也要占一定空间,所以如下例,实际只能放7948的数据,一旦超过,就产生行链接

--无
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. 本来是放的下的
2. 因为更新使row size变大了,一个block里又不足以放下增加的空间(PCTFREE相关),则产生行迁移
3. 容易发生在PCTFREE较小,对类似varchar类型的update又很多的表上
4. 无法避免,但通过把数据导出导入进行清除

例子:
--无
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了,产生行迁移
--有
update test7948_vchar set e='123456789'
posted @ 2010-06-13 14:08 Jcat 阅读(215) | 评论 (0)编辑 收藏
随着Oracle收购SUN,今天又爆出SAP收购Sybase的大料。

现状:
Oracle和IBM已经成为诺亚方舟级的厂商,啥都有。
微软,SAP成为航母级的厂商,软件方面啥都有,但目前没有硬件。

猜想:who's next? Dell? HP?
不然微软把Dell收了吧,组成BDll公司;
然后SAP和HP合并为SHP
posted @ 2010-05-14 11:24 Jcat 阅读(222) | 评论 (0)编辑 收藏
--创建一个大一点的TEMP表空间
create temporary tablespace temp1
tempfile '/oracledatafile/temp01.dbf' SIZE 100m autoextend on next 100m maxsize 5000m;
 
--切换默认TEMP表空间
alter database default temporary tablespace temp1;

--删掉以前的TEMP表空间
drop tablespace temp including contents and datafiles;
posted @ 2010-04-30 11:05 Jcat 阅读(268) | 评论 (0)编辑 收藏
1. 物化视图由于是物理真实存在的,故可以创建索引。




--为基表创建MLOG
--创建物化视图时应先创建存储的日志空间,否则建MV时报错
--ORA-23413: table "SCOTT"."EMP" does not have a materialized view log

create materialized view log on scott.emp
tablespace test
/


--创建物化视图
create materialized view test_mv
tablespace test
parallel (degree 4)
build immediate refresh fast
enable query rewrite
as
select * from scott.emp
/


--查看一下结果,果然很符合物化视图的定义,一个表+一个视图
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  (这就是那个存储表)

--查看MLOG的情况
--注意:MLOG的所属和MV的所属并不是同一个
SQL> select log_owner, master, log_table from dba_mview_logs
LOG_OWNER    MASTER    LOG_TABLE
---------------------------------
SCOTT        EMP    MLOG$_EMP (MLOG其实也就是一个表)

SQL> desc scott.mlog$_emp;
Name            Type
-------------------------------
EMPNO            NUMBER(4)
SNAPTIME$$        DATE
DMLTYPE$$        VARCHAR2(1)
OLD_NEW$$        VARCHAR2(1)
CHANGE_VECTOR$$        RAW(255)



--删除MLOG
drop materialized view log on 物化视图所依赖的表名; 
--删除物化视图
drop materialized view 物化视图名;
posted @ 2010-01-13 00:04 Jcat 阅读(509) | 评论 (2)编辑 收藏
注意,为了能在终端看见put_line的输出,还需要先开启
set serveroutput on

 

--用来测试的表
create table test_tri(
a1 int,
a2 int
)
tablespace test


-----行级insert触发器
-----
1) 插入的一行新数据保存在:new
2)
insert触发器没有:old值
3) 对:new的修改,只能定义在before类型的触发器中

---触发器语法---
create or replace trigger 名称
[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;
/

--测试

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(由触发器生成的值)
         2          3



-----DDL触发器-----
--任何create语句都会触发这个语句

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;
posted @ 2010-01-11 14:58 Jcat 阅读(243) | 评论 (0)编辑 收藏
Oracle建好后,tnsnames和listener中自动就带有如下内容,这里咱们就来解释一下这些东西是干什么用的

----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 Communication
When 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
默认安装时,会安装一个PL/SQL外部程序(extproc--这是程序名)条目在listener.ora中,是oracle为调用外部程序默认配置的监听,它的名字(也就是SID)通常是ExtProc或PLSExtProc
但一般不会使用它,可以直接从listener.ora中将这项移除,因为对ExtProc已经有多种攻击手段了,在不使用外部程序时,Oracle也是建议删除的。



extproc的作用
就是在pl/sql中调用外部语句,如c,java写的过程。
现在,Oracle已经全面支持JAVA了,这东西也就过时了,之所以继续保留是考虑到兼容以前老版本的数据库实例。

[oracle@dcm bin]$ extproc
Oracle Corporation --- TUESDAY   JAN 05 2010 21:58:23.878
Heterogeneous Agent Release 10.2.0.1.0 - Production

posted @ 2010-01-05 21:59 Jcat 阅读(634) | 评论 (0)编辑 收藏
--登录sys用户,创建一个测试用户,权限可以给大点
SQL> create user test identified by xxxxx;
SQL> grant connect to test;
SQL> grant resource to test;
SQL> grant dba to test;


--登录test用户,开始测试
--建个测试表
create table test_table(id int, time timestamp);

--创建Job
begin
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函数同SQLServer的isnull函数
    start_date => null, --一激活,就开始
    repeat_interval => 'FREQ=SECONDLY;INTERVAL=10');
end;

FREQ用来指定间隔的时间周期,可选参数有:YEARLY,MONTHLY,WEEKLY,DAILY,HOURLY,MINUTELY,SECONDLY。

--光创建没用,还需要激活;也可以在创建时,直接把enable属性设置为true(enabled => true
select job_name, enabled, run_count from user_scheduler_jobs;
JOB_NAME                       ENABL  RUN_COUNT
------------------------------ ----- ----------
TEST_JOB                       FALSE          0


begin
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


--停止任务
begin
dbms_scheduler.disable('test_job');
end;

--删除任务
begin
dbms_scheduler.drop_job('test_job');
end;
posted @ 2009-12-17 16:13 Jcat 阅读(226) | 评论 (0)编辑 收藏

一致和并发是对立的,需要根据应用,选择权宜之计


数据不一致的现象

---事务内单SQL的情况---
1.脏读-Dirty Read:本事务读取了其它事务尚未提交的修改数据
例子:读了不该读的
1:00 x=1
1:01 A用户 Update x=2(但未commit)
1:02 B用户 Select x --> x=2
合理的情况是x仍然等于1

---事务内多SQL的情况(典型的如,先查再改)---
2.不可重复读-Non Repeatable Read
例子1:自相矛盾
1:00 x=1 y=2
1:01 B用户 Select x,y --> x=1 y=2
1:02 A用户 Update x=2; Commit;
1:03 B用户 Select x+y --> x+y=4
首先这个结果从单条SQL的角度看,是没有问题的。但是,如果把B的两次查询看作一个整体(事务),那么合理的情况应该是
  x+y仍然等于3
  或者B再进行一次事务,得出 x=2 y=2 x+y=4 的结果


例子2:更新丢失
1:00 x=1
1:01 B用户 Select x --> x=1
1:02 A用户 Select x --> x=1
1:03 A用户 Update x=2; Commit;
1:04 B用户 Update x=3; Commit;
同样,从单条SQL来讲,没有任何问题。
但是从逻辑的合理性讲,一般的更新操作都是先查再改,换言之
  A真正想做的是Update x from 1 to 2
  B真正想做的是Update x from 1 to 3
但最终却造成了在B不知情的情况下,把B的初衷改为了Update x from 2 to 3


3.幻影读-Phantom Read
例子:读到了未来
1:00 X1=1 X2=2
1:01 B用户 Select Xi --> X1=1 X2=2
1:02 A用户 Insert X3=3; Commit;
1:03 B用户 Select sum(Xi) --> re=6
其实道理和之前的不可重复读相同,只不过是由Insert引起的罢了。
(甚至Delete也会引起类似的问题,但好像学术界并没有对Delete进行讨论)




Isolation Level
Read Uncommitted:1,2,3都会发生
  Oracle中严格禁止脏读
  在SQL Server 7.0中,是可以选择该级别的
Read Committed:发生2,3(Oracle的默认级别)
Repeatable Read:发生3
Serializable:都不发生


Oracle的实现方式
Read Committed:默认就实现
Repeatable Read:
  1. 悲观锁(select ... for update),影响并发
  2. 乐观锁(update where 所有字段都作为条件),不影响并发
Serializable:
  alter session set isolation_level=serializable/read only
posted @ 2009-12-05 17:45 Jcat 阅读(195) | 评论 (0)编辑 收藏


因为在客户那工作不能上网,决定办一张3G上网卡(公司报销),中午分别去电信和移动了解了一下:
电信 960元  7个月  300小时/月
移动 880元  7个月  15G/月 (目前推广期,不限流量)
(都包含上网猫)
这样算下来还是移动的便宜,去搞了个移动的。

关于移动的上网猫,开始给我测试的时候用的是华为的、白色、流线型还挺好看。最终给我的是一个鸟公司的(敏讯),方形真难看,太大了,号称还是升级版。

速度嘛,看网页没啥问题,Outlook下邮件也很快,在线听歌也没问题,在线电影就不去尝试了,免得伤自尊,办公足够了。玩开心网有点卡。(我以前就用过联通的CDMA-2G上网,那叫一个慢呀)

这个帖子就是用3G网络发的,哈哈。同时纪念一下2年后重回BMW做项目。
posted @ 2009-09-17 19:09 Jcat 阅读(208) | 评论 (0)编辑 收藏
扇区(sector):最小的可寻址单元,512byte
磁道(track):一圈扇区
磁柱(cylinder):一摞磁道

每一磁道的扇区数是一样的,但是存储密度不同,外疏内密。

为什么要外疏内密?
角速度相同时,线速度与半径成正比:
硬盘为了提高其轴寿命,轴的转动速度是一定的。磁头在硬盘上读写数据是近乎于圆弧的路线,而越往外,线速度就越快。为了保证读取的准确性只能减小外道的密度使磁头读取数据的时间间隔是相同的。


有待研究:早期的磁盘每个磁道上的扇区数目是一样,显然浪费了外圈的容量,后来为了增大磁盘容量采用了新技术,也就是说越往外每磁道扇区数目越多。

posted @ 2009-09-14 15:50 Jcat 阅读(357) | 评论 (0)编辑 收藏
字符设备:按照字符流的方式被有序访问,不能随机存取,如键盘、串口打印机、磁带。

块设备:能够随机(不需要按顺序)访问固定大小数据片(chunks),采用块缓冲技术,如硬盘、软盘、光驱。

裸设备:是一种没有经过格式化,不被Unix通过文件系统来读取的特殊字符设备。
现在问题来了,Oracle在使用裸设备时(如ASM、甚或表空间直接建在裸设备上),难道还是顺序存取?显然不符合事实。
其实,说裸设备是字符设备,只是从操作系统的角度来说的;从使用裸设备的应用程序(如Oracle)的角度,还是块设备,Oracle会去对磁盘进行分块管理。

逻辑卷是逻辑概念,可以包含多块物理硬盘,实现了存储跨盘功能,同时提供了数据复制机制,提供了数据安全保护机制。

--------------

裸设备适用于每次改动数据较小、需大量并发交易,OLTP;
对于大规模顺序读写,裸设备性能是最差的,所以对OLAP,应使用块设备或卷。

posted @ 2009-09-14 13:45 Jcat 阅读(574) | 评论 (0)编辑 收藏
--创建一个分区表
create table scott.testpart
(
    TEXTDATE   VARCHAR2(8)
)
partition by range ( TEXTDATE )
(
     partition p1 values less than ('20090201'),
     partition "p2" values less than ('20090301'), --注意这里的双引号
     partition pm values less than (MAXVALUE)  
)


--插入一些数据(顺便实践一下双层循环)

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循环里面了
        END LOOP;
END;


--需要先进行分析,否则num_rows列将为空
analyze table scott.testpart compute statistics;

--查看各个分区的情况
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因为加了引号仍然是小写(但并不显示引号,这点比较讨厌),没加引号的会显示为大写


--验证数据确实进入了正确的分区
select * from scott.testpart partition(p1);
TEXTDATE
--------
20090101
20090102
20090103

--创建p2时有引号,使用p2时也就需要引号。
--特别的,用一些第三方客户端创建分区表时,生成的SQL往往会自动加上引号,而查看DBA_TAB_PARTITIONS时又看不出来,所以遇到下面的问题,可以加个引号试试。
select * from scott.testpart partition(p2);
ERROR at line 1:
ORA-02149: Specified partition does not exist

select * from scott.testpart partition("p2");
TEXTDATE
--------
20090201
20090202
20090203


--其它相关
select * from scott.testpart;
truncate table scott.testpart;
drop table scott.testpart;

posted @ 2009-08-18 18:17 Jcat 阅读(247) | 评论 (0)编辑 收藏
股票的面值,是股份公司在所发行的股票票面上标明的票面金额,它以元/股为单位,其作用是用来表明每一张股票所包含的资本数额。在我国上海和深圳证券交易所流通的股票的面值均为壹元,即每股一元。
一般来说,股票的发行价格都会高于其面值。当股票进入流通市场后,股票的面值就与股票的价格没有什么关系了。股民爱将股价炒到多高,它就有多高。

按股东权利分类,股票可分为普通股、优先股和后配股。在我国上交所与深交所上市的股票都是普通股

股息红利作为股东的投资收益,是以股份为单位计算的货币金额,如每股多少元。但在上市公司实施具体分派时,其形式可以有四种:这就是现金股利、财产股利、负债股利和股票股利等。沪深股市的上市公司进行利润分配一般只采用股票红利和现金红利两种,即统称所说的送红股和派现金。
当上市公司向股东分派股息时,就要对股票进行除息;当上市公司向股东送红股时,就要对股票进行除权。
我国上市公司中约有一半以上的股份为国家股,且其股权代表基本上都是上市公司的经营管理人员。由于切身利益的影响,经营管理人员基本上都赞同企业的发展与扩张,所以我国上市公司的分红中,送红股的现象就非常普遍。
posted @ 2009-07-29 11:17 Jcat 阅读(152) | 评论 (0)编辑 收藏
硬链接
[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

链接数只是和硬链接相关的一个概念
从链接文件可以跟踪到软链接的指向(无法反向跟踪)



---------------
由于inode这种文件系统结构不是双向的,不能查找一个inode被reference了多少次。我们只能通过一些技巧来跟踪硬链接。
1. 通过链接数,我们可以知道哪个文件有硬链接(大于1)
2. 查找该文件的inode id
[oracle@dcm ~]$ ls -i hard.link
1573158 hard.link
3. 通过inode id查找文件(如果需要遍历的目录很多,速度自然可想而知)
[oracle@dcm ~]$ find -inum 1573158
./hard.link
./original.file
4. 硬链接本质上是多个dentry指向同一个inode,所以并没有主从之分,每个dentry都是平等的。

posted @ 2009-07-14 17:40 Jcat 阅读(237) | 评论 (0)编辑 收藏
--修改后重新启动数据库,永久生效
SQL> alter system set nls_date_format='yyyymmdd';
ERROR at line 1: --不能是memory scope(默认是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  --这个时候还没生效
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
nls_date_format                      string

--重启数据库后
SQL> show parameter nls_date_format
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
nls_date_format                      string      yyyymmdd

SQL> select sysdate from dual;
SYSDATE
--------
20090627



--只对当前session有效,重登录一次SQLPLUS,效果就消失了
SQL> alter session set nls_date_format='yyyy-mm-dd';   --这个格式也很常用 yyyy-mm-dd hh:mi:ss
Session altered.  --同时会覆盖初始化参数里的设置

SQL> select sysdate from dual;
SYSDATE
----------
2009-06-27
posted @ 2009-06-27 16:18 Jcat 阅读(667) | 评论 (0)编辑 收藏
Oracle所有对象的相关信息都可以通过静态数据字典来查找,但数据字典实在太多,也记不清名字。
因为数据字典都是以DBA_开头的视图,所以可以想办法先把它们列出来。
btw,DBA>ALL>User

以下两句结果上是等效的
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 '\';



例子:
我想查看数据文件的相关信息,但是从DBA_DATA_FILES里,并没有看见Temp表空间的数据文件的信息。
于是可以尝试如下搜索:
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    --找到嫌疑犯,进去一看,果然记录的是关于Temp表空间的数据文件的信息
DBA_TEMP_FREE_SPACE


列一些常用的在这吧

posted @ 2009-06-18 22:42 Jcat 阅读(286) | 评论 (0)编辑 收藏
这两个命令都是用来更改一些数据库配置的,所以经常容易混淆,如:
>alter database drop logfile group 1;
>alter system switch logfile;
>alter system kill session 'sid,serial#';

为了方便记忆,归纳如下:
alter database (改变数据库--database)
和物理文件直接相关的操作

alter system (改变实例--instance)
不直接牵涉到磁盘文件的操作


当然,这只是为了方便记忆,只满足大部分的情况,并不是所有的命令都能套到这个框框里,最终还是用熟了就记住哪个是哪个了。


---外传---
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

posted @ 2009-06-16 12:32 Jcat 阅读(208) | 评论 (0)编辑 收藏
《道路交通安全法实施条例》第四十九条规定,机动车在有禁止掉头或者禁止左转弯标志、标线的地点以及在铁路道口、人行横道、桥梁、急弯、陡坡、隧道或者容易发生危险的路段,不得掉头;机动车在没有禁止掉头或者没有禁止左转弯标志、标线的地点可以掉头,但不得妨碍正常行驶的其他车辆和行人的通行。在允许掉头的地点设有掉头专用信号灯的,应当在绿灯期间掉头;未设有掉头信号灯的,但有相应的标志标明在红灯或者绿灯期间掉头的,应当按照标志的指示掉头;既无掉头专用信号灯,又无其他标志指示的,掉头时可不受信号灯限制,但掉头时不得妨碍正常行驶的车辆和行人通行。

-----

有下列情形之一的,依法予以处罚:
   (1)在设有禁止掉头(禁止左转弯)标志、标线的地点掉头的;     
   (2)在人行横道处掉头的;
   (3)在非禁止掉头的地点掉头与正常行驶的车辆、行人发生交通事故的,按掉头时妨碍正常行驶的车辆通行或掉头时妨碍正常行驶的行人通行的行为予以处罚。
   (4)没有从左侧第一条车道(设置专用掉头车道的除外)掉头的,按掉头时未按规定驶入最左侧车道的行为进行处罚。

-----

(一)下列情形,不属于违法行为:
    (1)在没有禁止掉头(禁止左转弯)标志、标线的地点掉头的;
    (2)在没有禁止掉头(禁止左转弯)标志、标线的路口,红灯期间或绿灯期间掉头的;
    (3)在黄色网格线内掉头的。

(二)有下列情形之一的,依法予以处罚:
   (1)在设有禁止掉头(禁止左转弯)标志、标线的地点掉头的;     
   (2)在人行横道处掉头的;
   (3)在非禁止掉头的地点掉头与正常行驶的车辆、行人发生交通事故的,按掉头时妨碍正常行驶的车辆通行或掉头时妨碍正常行驶的行人通行的行为予以处罚。
   (4)没有从左侧第一条车道(设置专用掉头车道的除外)掉头的,按掉头时未按规定驶入最左侧车道的行为进行处罚。


posted @ 2009-05-29 00:46 Jcat 阅读(206) | 评论 (0)编辑 收藏
运行该Sub,所有单元格的字母都会变成大写的
Sub  cap()
Dim  cell  As  Range
For   Each  cell In UsedRange
    cell.Value 
=   UCase $(cell.Value)
Next
End Sub

给定一段时间,计算出什么时候到期
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

posted @ 2009-05-20 20:20 Jcat 阅读(181) | 评论 (0)编辑 收藏
登录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 ~]$ rman
Recovery 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)



因为数据库是Open的,且又是非归档模式,所以无法进行在线全备份

RMAN> backup database;
ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode

关了,整成mount状态
RMAN> shutdown
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount
connected to target database (not started)
Oracle instance started
database mounted



开始数据库全备份

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
------- ---- -- ---------- ----------- ------------ ---------------
      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)? YES
deleted 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

posted @ 2009-05-13 15:47 Jcat 阅读(304) | 评论 (0)编辑 收藏
01555
ORA-01555: snapshot too old    回滚段不够用了
可以采取的措施有:
1、应用程序尽量避免巨表的漫长查询操作,改传统的cursor游标为bulk collect;
2、尽量程序中不要使用大事务量的增删改操作,同时记得及时commit;
3、加大undo表空间和加大undo的retention。

10046
Event 10046是oracle用于系统性能分析时的一个最重要的事件。
posted @ 2009-04-23 20:33 Jcat 阅读(238) | 评论 (0)编辑 收藏
Ora s le

74亿美元呀,现在Oracle可以和18摸全面抗衡了!

简直就成了IT届的 GE vs 西门子!

oracle-sun.JPG


----收购后的格局----
航母级:IBM  vs  Oracle+SUN
软件:Microsoft,SAP,RedHat,Sybase(小赛的级别是不够放在这的,我觉得它最终也会走上被收购的道路)
硬件:HP,Dell,Fujitsu


----预测----
1. MySQL是生是死?
Oracle是当今企业级数据库的老大,MySQL是当今互联网应用的老大。
如果小O把小My干掉,并不代表小My的那部分市场会成为小O的;相反,如果小O能好好照顾小My,那简直就无敌了。
个人预测:75分,只要小O能够保持一颗开放的心,小My应该能有很好的发展。

2. Solaris是生是死?
小O一直致力于发展Linux技术(比如他和小红合作搞的Unbreakable Linux),是把Solaris拿来当补充,还是干掉?
个人预测:60分,不会有太大发展,保持现状。

3. Java的发展方向?
Oracle在很多方面都很需要Java,这是好的一面。
但是Java作为一门技术,而不是一个产品,需要有一个中立的代表,SUN以前的态度还是不错的。但小O和小I显然是誓不两立的,会不会导致Java世界的分裂?
个人预测:70分,这个可能最难预测,实在不希望看到不好的结果。

4. 硬件部分
这是小O没有的,但是不排除小O把它剥离卖出去。但我又觉得这种可能性很小,因为小O最不缺的就是钱,而且这是小O去和小I叫板的一大资本。
个人预测:80分,以后Oracle也可以玩total solution的游戏了。



----关系----
  和IBM,这回真的成为死死对头了
  和HP、Dell,选什么产品还是由市场决定的,小O总不能强买强卖SUN的服务器吧,还好吧
  和RedHat,小O和小红正在一起搞过Unbreakable Linux,我觉得小O会继续搞下去
  和Sybase,这回搞得三大主流操作系统(Windows、AIX、Solaris)都有自己的数据库了,Sybase的数据库将越来越难卖了
  和SAP,Microsoft,跟这次收购没太大关系,但震撼一定不小
posted @ 2009-04-21 10:27 Jcat 阅读(222) | 评论 (0)编辑 收藏
--最多同时运行的JOB个数;如果太小,JOB就排队等待;如果为0,就没有JOB会被执行。
SQL> show parameter job_queue_processes
NAME                                        TYPE          VALUE
--------------------------         ----------    -------------
job_queue_processes         integer          10


--一个什么也不做的SP

CREATE OR REPLACE PROCEDURE mytest
IS
BEGIN
    NULL;
END;

--一个往表里写数据的SP
CREATE OR REPLACE PROCEDURE mytest
IS
BEGIN
    insert into test_table values(...);
END;

--定时调用SP,10秒(86400秒=1天)
SQL> VARIABLE job_id NUMBER;
SQL> BEGIN
           -- :job_id中的冒号表示冒号后面的是变量,类似SQL Server的@
           DBMS_JOB.SUBMIT(:job_id, 'mytest;', sysdate, 'sysdate + 10 / 86400') ;
           COMMIT;  --记得一定要commit哦
           END;

--查看刚才生成的Job ID
SQL> set serveroutput on
SQL> execute dbms_output.put_line(:job_id)  --这里倒是不需要commit,直接execute就好了
318

--查看所有Job
 select * from user_jobs;

--删除Job
SQL> BEGIN
           DBMS_JOB.REMOVE(123); --123是Job ID
           COMMIT;
           END;


如果Job由于某种原因未能成功运行,Oracle将重试16次,之后如果还未能成功运行,将被标记为Broken。



http://www.blogjava.net/Jcat/archive/2009/12/17/306315.html
从10g开始,DBMS_SCHEDULER 逐步会替换掉 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&gt; alter system set job_queue_processes=0;

posted @ 2009-04-16 15:42 Jcat 阅读(751) | 评论 (0)编辑 收藏
登录  shell> mysql -u用户名 -p密码

查看数据库  mysql> show databases;
至少会显示出两个数据库mysql和test,这是系统自建的,供大家练习用。

使用数据库  mysql> use 数据库名

查看表  mysql> show tables;

查看表结构  mysql> desc 表名;

备份数据库  shell> mysqldump -uroot -p密码 数据库名 > 备份的文件路径
posted @ 2009-03-27 22:33 Jcat 阅读(274) | 评论 (0)编辑 收藏
SunOS是Sun的操作系统最初叫法,SunOS主要是基于BSDUnix版本;
SunOS 5.0开始,SUN的操作系统开发开始转向System V Release 4,并且有了新的名字叫做Solaris2.0
Solaris 2.6以后,SUN删除了版本号中的"2,因此,SunOS 5.10就叫做Solaris 10

最后"SunOS"这个词被用做专指Solaris操作系统的内核;而Solaris被认为是由SunOS,图形化的桌面计算环境, 以及它网络增强部分组成。
 
  
---Solaris与Sunos的版本转换---
Solaris 10 = SunOS 5.10
Solaris 9 = SunOS 5.9
Solaris 8 = SunOS 5.8
Solaris 7 = SunOS 5.7

Solaris 2.6 = SunOS 5.6
Solaris 2.5 = Sunos 5.5

  

------------------
Solaris也有分服务器版和个人版,它们分别是:
   服务器版:sparc
   个人版:x86
虽然Solaris在SPARC上拥有强大的处理能力和硬件支持,但是在Intel x86上性能却未如人意。
posted @ 2009-03-13 12:19 Jcat 阅读(763) | 评论 (2)编辑 收藏
为了跟老外聊天,装了个Skype。后来发现可以用来打IP电话,超值!

skype.JPG

这东西很适合我们这些北漂专门用来给家里打长途:

1. 地点固定,我都是周末的晚上在家往老家打电话,肯定是在电脑前的
2. 因为Skype不分本地长途,用来打长途更体现优势
3. 通话时间长,我一般一周打一次,每次30分钟左右,就更更体现优势了


不适合打本地电话:

1. 拨打的地点都是不可预期的,总不能要电话了,还得把电脑打开、上网
2. 上班的时候倒是都在电脑前,但可以用公司的座机嘛,免费的
3. 省钱的优势不明显:移动2.5;固话2.2角(管前三分钟),之后1.1



Sample: 每月往家打100分钟(一周一次,每次25分钟)
   Skype=100*0.075+3=10.5元
   手机9点前=100*0.35=35元
   手机9点后=100*0.22=22元

posted @ 2009-02-27 13:52 Jcat 阅读(344) | 评论 (0)编辑 收藏
基金的买卖时间和大盘一样,但是网上一般可以随时下单;如果是闭盘时间下的单,就顺延到下一个开盘日购买。

今天看到的基金净值,其实是昨天的值。
今天购买的基金,其净值明天才能看见。

下午3点以前购买基金,算作今天购买;3点以后,算作明天购买,即净值要在后天才能看见。

基金管理费:一般为1%左右,每天根据资产总额提取,净值是已经提取了管理费和托管费后的价格。

---------------------------

基民首先要弄清楚“认购”与“申购”的区别。
1. 认购是针对新基金而言的,这个时候所认购的基金并不产生份额净值,成交价以1元面值为基准。
2. 申购则指在基金成立后,投资者申请购买基金份额的行为。

无论是认购还是申购,交易时间内投资者可以提交认/申购申请。
投资者只有在交易日下午3点收盘之前提交申购请求才能在当日生效,并可能成功交易。

一般来说,投资者在份额发售期内已经正式受理的认购申请不得撤销。
对于申购申请,投资者只有在当日 15:00前提交撤销申请,才能予以撤销。

在基金申购的过程中,投资者面临着一个“未知成交价”的交易风险,这是因为申购价格以当日的基金份额净值为基准进行计算,而成交当日的基金份额净值只能在下午3点收盘之后诞生,这个净值一般会在下一个交易日开始之前公告。

------------------------------

收购费率是有折扣的(根据不同的银行),如易方达前端申购费率是0.8%,但是如果用广发卡费率是0.3%,1w元能省50元呢。
"优惠费率不按金额分档,持有广东发展银行理财通卡的个人投资者的优惠认购费率或申购费率统一为0.3%。"-- From 易方达
posted @ 2009-02-22 17:18 Jcat 阅读(408) | 评论 (2)编辑 收藏
Habit 1: Be Proactive
Change 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 Mind
Develop a principle-centered personal mission statement. Extend the mission statement into long-term goals based on personal principles.

Habit 3: Put First Things First
Spend 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/Win
Seek 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 Understood
First 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: Synergize
Through 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 Saw
Take 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.

 

posted @ 2008-12-25 16:35 Jcat 阅读(300) | 评论 (0)编辑 收藏
很多时候,在我们进行数据库操作时,比如drop user,drop table等,经常会遇到这样的错误:
ORA-00604: error occurred at recursive SQL level 1 .

关于Recursive SQL错误:
我们知道,当我们发出一条简单的命令以后,Oracle数据库要在后台解析这条命令,并转换为Oracle数据库的一系列后台操作,这些后台操作统称为递归SQL。
比如create table这样一条简单的DDL命令,Oracle数据库在后台,实际上要把这个命令转换为对于obj$,tab$,col$等底层表的插入操作。Oracle所作的工作可能比我们有时候想的要复杂的多.。

所以对于这样的提示,很多时候是没有丝毫用处的。

这时,我们需要更详细的信息,sql_trace就是一个好办法。
sql_trace实际上就是Oracle内部事件10046的第一个级别,即level=1。通过event 10046, 我们可以得到详细的数据库会话的信息,每个会话究竟在干什么,在等什么。通过对这个事件的学习,我们可以深入的理解和调整Oracle。


结合eygle的文章整理的,SQL Trace更详细的用法请见原文


----------

Event 10046是oracle用于系统性能分析时的一个最重要的事件。当激活这个事件后,将通知oracle kernel追踪会话的相关即时信息,并写入到相应trace文件中。这些有用的信息主要包括sql是如何进行解析,绑定变量的使用情况,话中发生的等待事件等。
Trace文件将会存放在 user_dump_dest 所指向的目录,如,C:\ent\oracle\admin\o10g01\udump

Event 10046可分成不同的级别(level),分别追踪记录不同程度的有用信息。对于这些不同的级别,应当注意的是向下兼容的,即高一级的trace信息包含低于此级的所有信息。
    level 1:跟踪sql语句,包括解析、执行、提取、提交和回滚等。
    level 4:包括变量的详细信息
    level 8:包括等待事件
    level 12:包括绑定变量与等待事件
其中,level 1相当于打开了sql_trace。

在当前会话启用event,可以利用alter session + 事件名称 + level:
SQL> alter session set event ‘10046 trace name context forever, level 12’;

关闭当前会话的event:
SQL> alter session set event ‘10046 trace name context off’;

这里应当值得一提的是,TRACE将消耗相当的系统资源,因此我们在使用TRACE的时候应当慎重。对于正式的系统,应当只在必要的时候进行TRACE操作,并且应当及时关闭。
posted @ 2008-12-19 15:19 Jcat 阅读(236) | 评论 (0)编辑 收藏
孙悦和菲尔.jpg
湖人vs雄鹿,第四节垃圾时间,孙悦终于替补出场。

孙悦失误了队友安慰他.jpg
上来就3个犯规,1个运球失误,显得很紧张,身体僵硬。又失误了,队友安慰他。
然后1个三分的机会,没进,动作很僵硬。

孙悦投进NBA第一球.jpg
终于有个中距离的机会,孙悦投中了,全场鼓掌!
后来又有一个反击的机会,孙悦篮下打板进了,继续鼓掌!


恭贺菜鸟的第一次NBA亮相!
posted @ 2008-12-08 13:07 Jcat 阅读(268) | 评论 (1)编辑 收藏
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.

终于还是没坚持下来,看来坚持不懈做一件很小的事也是很难的。



posted @ 2008-12-03 12:07 Jcat 阅读(258) | 评论 (0)编辑 收藏
Oracle Database的大版本号由两部分组成:数字+字母,数字自然是大版本号,字母则是代表了这个版本的“中心思想”

8i(1998),9i(2001):那时候正好互联网兴起,i就代表internet(网络)

10g(2003),11g(2007):现在主推分布式计算,g就代表grid(网格)



另外,还有个11i,这容易引起混淆,其实11i是指Oracle EBS(E-Business Suite电子商务套件)的版本号,其实就是Oracle ERP。(这好像跟Oracle Database没什么必然联系,我也不知道这个i代表什么)

这也说明Oracle不等于Oracle Database。平常我们说“Oracle”,一般都是指Oracle Database,当然这是它最著名的产品;不过,其实Oracle早就已经不是一家数据库厂商了,而是航母级厂商,东收西购,啥都有了。


我见过这样的问题:“
从版本命名来看8i-9i-10g-11i,是不是意味着grid只是昙花一现?”显然这就是混淆了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




posted @ 2008-11-17 22:32 Jcat 阅读(1324) | 评论 (1)编辑 收藏
Groovy把最常用的东西都设置成default了,经常可以省这省那的(比如括号、分号、public等);又加上闭包,初学的时候,有些代码,一眼望去,都分不清是方法、是类、还是闭包。
这里先简单总结一下常用的修饰符。

package jcat.bit.g

/*
修饰符有三类:
1. static
2. 作用域:public(默认), private, protected.
3. 类型:def(默认,动态), void(无类型,静态), 其它常规静态类型
*/
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 = 可以返回任何类型,包括void
        return "t_static_def"
    }

    
static t_static() { // 有其它修饰符可以省略def(默认public + def
        return "t_static"
    }

    
public def t_public_def() {
        
return "t_public_def"
    }

    
public t_public() { // 默认def
        return "t_public"
    }

    def t_def() { 
// 至少要有一个修饰符,所以这个def不能省略; 且默认public
        return "t_def"
    }

    
static void t_static_void() {
        
//return "t_static_void"    // cannot return an object from a method that returns "void"
    }
}
posted @ 2008-11-10 12:30 Jcat 阅读(1423) | 评论 (0)编辑 收藏

用JDBC操作数据库,对比一下Java和Groovy。

环境:SQL Server 2000 (记得打补丁SP4,不然JDBC访问会报错)
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
));  // 数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    //直接用数据库的字段名就可以操作结果集了,不用去数id
        }

    }
}


总结
1. 建立查询,差别不大,都是JDBC那一套;Groovy不用处理异常
2. 处理查询结果,Groovy因为有闭包,处理这些迭代问题很方便
3. Groovy不用关闭
posted @ 2008-11-07 15:02 Jcat 阅读(1653) | 评论 (3)编辑 收藏

1. 闭包代表(定义)了一段代码(操作):光看这一句,其实方法也能实现相同的功能呀。
2. 闭包可以作为方法的参数:这才是闭包的特殊之处和真正意义。


下面演示一个只有闭包能做,方法做不到的例子。

方法的作用是提炼共性,再代之以不同的参数。即对不同的“数据”进行相同的“操作”。从3个loop可以看出:
    Comm1:相同的数据
    Comm2:相同的for循环
    Diff1:循环体内执行的操作不同

Comm1很好搞定,参数aa就是提炼出的共性
Comm2看似是共性,却很难提炼,因为for循环和循环体内的操作实际是一个整体;Comm2被Diff1纠缠,3个loop是完全不同的3组操作,无法提炼。

比如,如果现在想要按照奇数循环,只能依次改动三个循环。 

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;  +=   2 ) {
    println aa[i]
}

//  loop2
for  ( int  i  =   0 ; i  <  aa.length;  +=   2 ) {
    print aa[i]
}

//  loop3
for  ( int  i  =   0 ; i  <  aa.length;  +=   2 ) {
    print aa[i] 
+   '   '
}


下面我们看看闭包的强大之处,Comm1和Comm2都被很好的封装在了loop方法里;Diff1则作为参数(闭包)传入loop方法。

static void main(String[] a) {
    
int[] aa = [123456]

    loop(aa) { println it }
    loop(aa) { print it }   
    loop(aa) { print it 
+ ' ' }
}
如果我们想要改变循环的方式,只需要改一处
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; += 2) {
        c.call(aa[i])
    }
    println 
' '
}

总结,闭包本身并没什么难点,关键是怎样合理的设计一个接受Closure类型参数的方法。从GDK的方法也可以看出,大多数接受闭包的方法都是和数组迭代有关(也即循环)。
posted @ 2008-11-07 02:04 Jcat 阅读(1522) | 评论 (2)编辑 收藏

Definition

    /*
        1. 变量是用来装“数据”的,闭包就是用来装“操作”的
        2. 和定义一个方法一样,闭包也可以有入参
       
*/
        Closure p 
=  {x  ->
            print x 
+   '   '
        }
        [
1 2 3 ].each(p)

        [
4 5 6 ].each({x  ->   //  闭包是可以匿名的
            print x  +   '   '
        })

        [
7 8 9 ].each {x  ->   //  括号是可以省略的
            print x  +   '   '
        }

        [
10 11 12 ].each {  //  it是默认的参数名字,所以这里连入参的定义都省了
            print it  +   '   '
        }


Using

package jcat.bit

class Test {
    
/*
    1. 闭包是对象,是Closure类的实例,所以:
        1)可以在类里定义Closure类型的属性
        2)可以在方法里定义Closure类型的变量
        3)可以定义一个方法,接收Closure类型的参数
    2. 闭包又有方法特质,毕竟它装的是“操作”,甚至可以像调用方法一样调用闭包
     
*/

    
static final Closure PRINT_STR = {  // 属性(类变量)
        println it
    }


    
static void main(String[] a) {
        
/*
        闭包类似Java的内部类,区别是闭包只有单一的方法可以调用,但可以有任意的参数,
        闭包用“{}”括起,“->”前面是参数,后面是处理语句,可以直接调用,也可以使
        用call调用。不管那种调用,最后groovy编译器都会把编译成对doCall方法的调用,
        这是groovy对闭包的一个隐藏方法。
         
*/
        PRINT_STR(
"像方法一样调用")
        PRINT_STR.call(
"作为Closure的实例,再调用相应的方法")


        Closure printLength 
= {String s ->  // 局部变量
            println s.length()
        }
        printLength(
"AAA")

        
/*
        通常,操作是死的,我们能动态代入的是“数据”。
        闭包使得我们可以动态的代入一段“操作”。
        “闭包是可以用作方法参数的代码块。”
         
*/
        closureAsParameter(
null, printLength)
        closureAsParameter(
"BBB", PRINT_STR)
    }

    
static void closureAsParameter(String s, Closure c) {
        
if (s != null) {
            c.call(s)
        }
    }
}



-----------------------------------------------------------------
附上一个Java的匿名内部类的例子,用来和闭包对比一下。
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);
}
posted @ 2008-11-06 18:50 Jcat 阅读(337) | 评论 (0)编辑 收藏
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.
posted @ 2008-11-05 23:53 Jcat 阅读(271) | 评论 (0)编辑 收藏
最近BI的项目不忙,抽空怀念了一下编程技术:

1. <Flex 3> 同事给了我份Flex的教程,把前三章看了一下,有了初步的了解;FlexBuilder也用了一把,不错,效果很绚丽。

2. <IDEA 8> 恰逢IDEA 8 EAP (Early Access Preview)发布,搞了一个装上试试。主要试了试对Flex的支持,感觉还有待提升。另外IDEA对内存的消耗似乎越来越多了,没做深入体验。

3. <Grails 1.0.3> 拿出了小二去年送我的生日礼物《Grails权威指南》,翻了翻,Hello World一会就做好了。打算再进一步体验一下。
posted @ 2008-11-04 22:04 Jcat 阅读(181) | 评论 (0)编辑 收藏
Boa
这是飞侠兄做的Flex网站,很好玩。
posted @ 2008-10-22 21:14 Jcat 阅读(175) | 评论 (0)编辑 收藏
2008

国庆这个假放的,一直没背单词,又要慢慢追赶了。


9-25
All bacteria are larger than viruses.

9-26
The thief has gotten into the room off the balcony.

9-27
The treaty bans all nuclear tests.

9-28
On their way back home, they encountered a band of robbers.

9-29
We heard the bang of a gun.

9-30
The company went bankrupt.

10-1
The patriots hold aloft the banner of independence.

10-2
He opened a snake bar.
They barred the street to traffic.

10-3
The path leads to a bare hill.

10-4
He barely remembered anything she has said that day.

10-5
I make a fair bargain with the shopkeeper.

10-6
The dog always barks at strangers.

10-7
The horses seemed to be satisfied with the comfortable barn.

10-8
The river is a natural barrier between these two nations.

10-9
Baseball is the national sport of the USA.

10-10
Charity towards others is the basis of her philosophy.

10-11
The garden was bathed in moonlight.

10-12
They were faced with a battery of questions.

10-13
She spent her summer vacation in Sanya bay.

10-14
Beams support the roof of a house.

10-15
I cannot bear BB's nagging any longer.

10-16
He has a dense beard.

10-17
I have lost my bearings in all this mass of facts.

10-18
XX saves money on behalf of BB.

10-19
He behaves respectfully toward the elderly.

10-20
She was beloved of all who knew her.

10-21
Fresh air and good food are beneficial to one's health.

10-22
I'll bet you that they will win the next game.

10-23
The service included some readings from the Bible.

10-24
The dealers are bidding against each other at the auction.
posted @ 2008-10-14 00:20 Jcat 阅读(590) | 评论 (2)编辑 收藏
2008

8-25
I saw the arrest of the thief.

8-26
The artificial flowers are quite beautiful.

8-27
Please assemble everybody in my office at 3'o clock.

8-28
It is hard to assess the impact of the war.

8-29
The firm's assets were taken over by the bank.

8-30
We assigned tomorrow morning for our meeting.

8-31
She spent most of her time associating with her friends.


9-1
I assume that you have heart the news.


9-2
I proceeded alone on the assumption that he would help.

9-3
He was assured a well paying job upon graduation.

9-4
Chinese athletes won many golden medals in the Olympic Games.


9-5
Attach a label to your suitcase.

9-6

Finally he attained his goal.

9-7
Her work attitude was poor.

9-8
The defendant was represented by his attorney.

9-9
What a singularly attractive lady!

9-10
My mother attributes her good health to careful living.

9-11
Many works of literature and art have a wide and devoted audience.

9-12
You will get an automatic increase in pay every year.

9-13
Some sailboats have auxiliary engines.

9-14
There are no tickets available for Friday's performance.

9-15
NY's avenue is famous for its advertising industry.

9-16
He avoid answering my question.

9-17
We have awaited your coming for days.

9-18
The university awarded him an honorary degree.

9-19
We are fully aware of the gravity of the situation.


9-20
I feel awful this morning.

9-21

He feel awkward with women.


9-22
He was a reporter by background.

9-23
He made a backward step.

9-24
Bacon and eggs are my favourite foods.
posted @ 2008-08-27 23:12 Jcat 阅读(310) | 评论 (2)编辑 收藏
世界强队从来不是靠抽签抽出来的,中国男篮,我爱你!

“进场的时候,我们把手放在一起,把自己交给这支球队,同时也把这支球队扛在自己肩上,我们所有的人都在为这个球队努力。” -- 大大的姚明
posted @ 2008-08-16 21:56 Jcat 阅读(145) | 评论 (0)编辑 收藏
中国体操男团,背负四年的压力,重获金牌,超感人;

中国男篮vs西班牙,把世锦赛冠军逼到打加时,虽败犹荣;

中国男足都是Sha Bi,窝囊废。
posted @ 2008-08-12 18:54 Jcat 阅读(203) | 评论 (0)编辑 收藏
又坚持了一个月,中间短了4、5天,后来靠每天多背一个,给补了回来。


7/25/2008
It is very essential to analyze the causes of his failure.

7/26/2008
This is an old family firm founded by their French ancestor.

7/27/2008
Can you anchor the boat in this storm?

7/28/2008
His family has lived in this ancient city for more than two centuries.

7/29/2008
The roof is at an angle of 120 degrees to the walls.
I would like to hear your angle in this dispute.

7/30/2008
The whole nation celebrated cheerfully the fiftieth anniversary of the founding of the PRC.

7/31/2008
These flies are annoying me.
We can annoy the enemy by air raids.

8/1/2008
BB's thesis was published in the college annual.

8/2/2008
We are not anticipating that there will be much trouble.

8/3/2008
The antique dealer has a display of his valuable antiques.

8/4/2008
He caused his wife great anxiety by driving a long distance alone.

8/5/2008
It's too late now, anyhow.

8/6/2008
It was apparent that they all understood.

8/7/2008
We are appealing for money to build a teacher's club.

8/8/2008
He had no appetite to fight.

8/9/2008
He won standing applause after he ended his speech.

8/10/2008
This is an appliance for opening cans.

8/11/2008
That pretty lady is a hopeful applicant for the position.

8/12/2008
They applied to return to China.

8/13/2008
They arranged an appointment for next week.

8/14/2008
We really appreciate the peace and quite of the countryside.
They deeply appreciate his thoughtfulness.

8/15/2008
The professor is easy to approach

8/16/2008
It is appropriate that you should save some money in case you lose your job.

8/17/2008
The decision met the committee's approval.

8/18/2008
His statement is approximate to the truth.

8/19/2008
One should not make an arbitrary decision as to what to do in the future.

8/20/2008
DXP is called the general architect of the construction of socialist modernizations in China.

8/21/2008
Don't argue with me, just do as you are told.

8/22/2008
At later stage, there arose an new problem which seemed insoluble.

8/23/2008
We aroused him from his deep sleep.

8/24/2008
She has arranged numerous contacts between  XX and BB.
posted @ 2008-07-28 22:23 Jcat 阅读(321) | 评论 (1)编辑 收藏
<What's Hash>
Hash,一般翻译做“散列”,也有直接音译为“哈希”的。

我们通常说的Hash,其实指的是Hash算法(即散列算法):把任意长度的输入,通过Hash算法,变换成固定长度的输出(即Hash值、散列值)。

Hash算法有多种实现形式,比如MD5、SHA1,这里就不对算法本身进行讨论了。重点谈谈Hash算法的特性和作用吧:
    1)Hash是一种压缩映射:散列值的长度通常远小于输入的长度(比如emule,任意大小是视频文件,都可以映射成一个固定长度的字符串,它就相当于这个文件的信息摘要)
    2)不同的输入可能会Hash成相同的输出:这是一个小概率事件,且采用安全性高的Hash算法时,两个不同的输入几乎不可能得到相同的Hash结果。
    3)与加密算法不同,Hash算法是一个不可逆的单向函数,不可能从散列值来唯一的确定输入值。



<What's Hash Table>

0. 在下面的讨论中,我们将用到三国这个例子:假设我们要做个存储结构,需要存储下来三国中的英雄,以及他们的详细信息。我们用他们的名字来作为存储的关键值,例如:刘备,关羽,张飞,曹操,孙权...n。

1. 一般的表
    name    age    身高    体重
    刘备    30    175    60
    关羽    28    190    80
    张飞    27    185    80
    ...n

这时,如果我们想要查找某个英雄,就需要一边遍历表,一边对名字进行比较。它的时间复杂度为O(n)--线性阶。

总结:记录在结构中的相对位置和记录的关键字之间不存在确定的关系,在结构中查找记录时需进行一系列和关键字的比较,查找的效率与比较次数密切相关。

2. 数组
    1)通过地址的访问方式(数组):Array[2],这里2就是它的“物理”地址,找到2所对应的内容是通过“直接定位”,而不是“遍历比较”。所以,在所有的线性数据结构中,数组的定位速度最快。它的时间复杂度为O(1)--常熟阶。

    这时,我们会想,那我们把刘-关-张-...n,按照1-2-3-...n的顺序放在一个数组里(数组的内容就是这个英雄的对象)不就可以直接定位了?
    arrayid    (name    age    身高    体重)
    1            (刘备    30    175    60)
    2            (关羽    28    190    80)
    3            (张飞    27    185    80)
    ...n


    2)但是:
        a)可你凭什么说刘=1,关=2呢?(显然不是叫你用拼音或者笔画排序)
        b)我们查找的时候,不可能用arrayid作为查找条件(那还查个P呀),怎样通过name=关羽,“计算”得到arrayid=2呢?


3. 散列表:其主要目的是用于解决数据的快速定位问题,也即,怎样通过关键字,计算(而不是遍历比较)得到物理地址。

1)存放时
    Hash(刘备)=13
    Hash(关羽)=7
    Hash(张飞)=26
    ...n


    arrayid    (name    age    身高    体重)
    ...
    7            (关羽    28    190    80)
    ...
    13          (刘备    30    175    60)
    ...
    26          (张飞    27    185    80)
    ...n


    我们也可以看出:
    a)散列,数据并非紧凑的、按顺序存入的:我们可以先在13的位置存上刘备,再在7的位置存上关羽;有些位置还可能一直是空的。
    b)空间换时间:因为散列,显然数组的大小要大于实际实际数据的数量。比如,即使我们只存刘关张3个人,我们也需要一个至少26的数组。

2)查找时,就很简单了
    Aarry[Hash(关羽)]=Array[7]

3)当然实际的hash算法,要比上述复杂,比如
    “把Key通过Hash算法转换成一个整型数字,然后就将该数字对数组长度进行取余,取余结果就当作数组的下标,将value存储在以该数字为下标的数组空间里;
    而当使用哈希表进行查询的时候,就是再次使用哈希函数将key转换为对应的数组下标,并定位到该空间获取value,如此一来,就可以充分利用到数组的定位性能进行数据定位。”

4)Hash冲突:前面说了,不同的输入是有可能hash成相同的输出的
    如果Hash(关羽)=Hash(张飞)=250,我们岂不是在存储过程中会遇到麻烦,怎么安排他们二位的地方呢?(总不能让二位打一架,谁赢了谁呆在那吧),这就需要一个解决冲突的方法。
    先存储好了关羽,当张飞进入系统时会发现关羽已经是250了,那咱就加一位,251得了。我们查找张飞的时候也是,一看250不是张飞,那就加个1,就找到了。
    更极端地,如果这时Hash(赵云)=251,张飞已经早早占了他的地方,那就再加1存到252呗。呵呵,这时我们会发现,当哈希函数冲突发生的机率很高时,可能会有一群英雄在250这个值后面扎堆排队。要命的是查找的时候,时间算法复杂度早已不是O(1)了。所以我们说理想情况下哈希表的时间算法复杂度为O(1)。
    这就是说哈希函数的编写是哈希表的一个关键问题,会涉及到一个存储值在哈希表中的统计分布。如果哈希函数已经定义好了,冲突的解决就成为了改变系统性能的关键因素。其实还有很多种方法来解决冲突情况下的存储和查找问题,不一定非要线性向后排队,如果有好的哈希表冲突的解决方法也能很大程度上提高系统的效率。


FYI,比较书面化的定义:
    理想的情况是能直接找到需要的记录,因此必须在记录的存储位置和它的关键字之间建立一确定的对应关系f,使每个关键字和结构中一个唯一的存储位置相对应。因而查找时,只需根据这个对应关系f找到给定值K的像f(K)。若结构中存在关键字和K相等的记录,则必定在f(K)的存储位置上,由此不需要进行比较便可直接取得所查记录。在此,称这个对应关系f为哈希函数,按这个思想建立的表为哈希表(又称为杂凑法或散列法)。



参考:
http://calmness.javaeye.com/blog/184465
http://blog.163.com/xx_snoopy/blog/static/12577162008426731299/

posted @ 2008-07-18 16:55 Jcat 阅读(541) | 评论 (0)编辑 收藏