每天进步一点点~

上一篇 / 下一篇  2008-04-07 22:28:16 / 天气: 舒适 / 心情: 高兴 / 个人分类:数据库

51Testing软件测试网D7PUr0ke5UC;j

    这几天在学习Oracel,每天争取把学到的总结一下。一些是简单的,不过还是要总结练习一下;还有的理解不深,有待慢慢充实;兴许有的还停留在理解的误区,有待发现。

J_)i6j;uGcK051Testing软件测试网 bGyHp&@!_4a N*K5f

各种数据库比较:(若理解有误的希望高手指点)

3P"re/F.RT3e\0

/o?/a:`$^kR0Oracle(甲骨文):性能好,对硬件要求不苛刻(反例:DB2),不同平台间的可遗址性,(服务器比例,
3j yi'vc [0unix>60%, NT<40%)只要不用于商业活动,可以无限期使用。
R m}x o7Y0Sql Server(Microsoft):只能在windows下运行,没有开放性,只适用中小企业,不像unix下可以运行大型数据库。51Testing软件测试网-k7d?OmR%n
Sybase:似乎有好多版本,有点麻烦。51Testing软件测试网:b:BLs~;V1~
BD2(IBM):适用海量数据。

S+b*_0^!jP(tq&`051Testing软件测试网eG,I4_N_;e9T

sqlpuls 操作:
k,G%z+U(p7s m*K0sqlpuls :oracle自带的dos下的sql操作环境
B"KT9a'Vi7LB0sqlpuls 用户名@SID_主机名  OR   用户名/密码@SID_主机名(这种情况密码是以明码显示的,而前者输入密码是没有屏显的)51Testing软件测试网,f']A}/q
SID_主机名,网络服务端51Testing软件测试网msz1aIu
roll back  OR  rollback;   //回滚,撤消所有没有提交的操作,51Testing软件测试网k uQ*aw%n-]
commit;                //提交,提交后DML语言才会生效51Testing软件测试网 `^6N-amb;g!E3xx

5M%Ay/EsrD0DDL数据定义语言:
(ilX [8E0表的建立和删除:
G1Y.t?h%g0create table 表名 (id number,name varchar2(20),age number); //number 回自动调节长度51Testing软件测试网*GM@E!i8B N&QU
drop table 表名;51Testing软件测试网'z pw:[+iy w
表结构的操作:51Testing软件测试网_[P:prI r
desc 表名;//查看表结构51Testing软件测试网:S0?8od9G np
alter table 表名 modify(name varchar2(30));51Testing软件测试网O| [1l H,R(`
alter table 表名 add(address varchar2(40));51Testing软件测试网&{ X/j(h(fW1z
alter table 表名 drop column address;51Testing软件测试网+H!jB)F7r4qN
rename 表名 to 表名1;

`J+i+?(My8^0

*?Qb9_R$rk0DML数据操作语言:
f1E$G~(A9O0insert into 表名 (id,name,age) values (11,'a01',23);
"l\ qkj$b0insert into 表名 values (11,'a01',23);
0bnv:~z`b2jn"M0insert into 表名 (id,name,age) values (11,null,23);51Testing软件测试网 };I*P2@\%ha(\-wF)L
update 表名 set age = 21 (where id = 1);51Testing软件测试网XmE6`2u Ps#B#u:q
delete from 表名;51Testing软件测试网N"At&M7B,D Dao
delete from 表名 where age < 18;51Testing软件测试网\,ip+T8]ov^
51Testing软件测试网1uuS8fL;E9r
带运算+、-、*、/, as, ||, distinct, is null, is not null, between ...and ..., in(list), not in(list),51Testing软件测试网 a t%Y9G B?
like '%', like'_', max(), min(), sum(), avg(), count(), order by , group by51Testing软件测试网t2Fqrkg.tB(r
select * from tab(tables)         //选取所有的表
e C_ty1\(u?0select name,age+35 from 表名;//如果属性有要对null进行计算的,目前我认为没什么结果,似乎还是空。51Testing软件测试网E(D2e8^h
select name (as) xingming from 表名;//别名的用处有待学习、发现,eg:自联接
&W UrFv0select name ||'shi'||age||'sui' from 表名;??????用处
hLeF#P`nwN6| {$lK0
select distinct age from 表名;//去重
;TSz?"q"PT0select * from 表名 where age is not null;51Testing软件测试网Nw%WW%v%Ejp
select * from 表名 where age between 18 and 35;//包含边界值51Testing软件测试网k}Z8_7NPw? M Hp
select * from 表名 where age in (12,13,14,16);51Testing软件测试网c `w-j)~.p*B*| I
select * from 表名 where age not in (12,13);51Testing软件测试网#@m0t%WL }
select * from 表名 where name like '%a' or name like 'a%' or name like '%a%';  
\.FY3`Sp5Bs0// '%' 代表0个或多个字符;'_' 代表单个字符51Testing软件测试网kdo d'h J.W u ^&ku*X
select * from 表名 where name like '_a' or name like 'a_' or name like '_a_'; 
F0i^$s7eB'L0G v5}0//like 一般比较慢 
(p ?:D \ x mM!^]0select max(age) from 表名 ;//min(),sum(),avg(),count(),
vwj%q~fB0select * from 表名 order by age (asc)/desc;51Testing软件测试网!F-{],FRN6P

/W%U_ l |G1z0DCL数据控制语言:主要用于设置和修改权限:
]ON;guqvQ0grant 操作 on 对象 to 角色;
1U*C;u2b(O*K B9q0
I$Xg [DX0优先级:算术运算符(+、-、*、/),NOT,AND,OR
&kae#s T y051Testing软件测试网IT_M9Rt|@
遗留:Oracle 与 Sql Server 语法完全一致吗?
b-X1|)C5E+@h q#a9cU0     alter into 可以添加记录吗?//我记得sql server 里是可以用alter into 批量加数据的。51Testing软件测试网 @(?*Z5E{2a9p

&\"D["p;s,hY9c!K(C0 51Testing软件测试网2x4S9~*E)Z


TAG: 数据库 oracle 入门

安然的个人空间 引用 删除 coffeexl   /   2008-04-08 17:56:33
补充一下:
select id,age,count(age) from 表名 where age>18 group by id,age having count(age)>1
安然的个人空间 引用 删除 coffeexl   /   2008-04-08 16:49:43
是的,还没有物理去重,说的好,后面我再找找物理去重的资料。
ava840823的个人空间 引用 删除 ava840823   /   2008-04-08 10:23:16
转啦
ava840823的个人空间 引用 删除 ava840823   /   2008-04-08 10:22:08
select distinct age from 表名;//去重
这个语句只是查询时不显示的重复的结果,不是物理删除重复语句吧?
 

评分:0

我来说两句

日历

« 2024-05-06  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 8517
  • 日志数: 14
  • 书签数: 2
  • 建立时间: 2008-03-13
  • 更新时间: 2008-11-28

RSS订阅

Open Toolbar