db2常用语句

上一篇 / 下一篇  2013-01-20 16:51:50 / 个人分类:数据库

8f@,}#lfH1v+H? Yr02013年第一篇日志,最近有点小忙51Testing软件测试网3v3G%Vf!x2L o }^
祝大家都能买到回家的火车票,虽然12306不给力,还好我们有猎豹可以用

7I)aB'k7x ~4c0

8^'|)`1L,ya\0get instance
h(Mm7H"C,Ft0获取当前实例名称
#R O H%FE2FV9{0get database manager configuation51Testing软件测试网nj2_s^
获取DBMS或DB的配置参数51Testing软件测试网&E-V6K)Cjs6f0H9Q
list db directory51Testing软件测试网kr0jh^E9y^#Bw
列出所有数据库51Testing软件测试网-XOep1egP
list tables for all51Testing软件测试网9x| Mk3C3T
显示数据库下所有表结构51Testing软件测试网c@Q:A1A
list tables for schema schemaname51Testing软件测试网/N!S)ut/i4x k
显示当前数据库中执行schema的表
[S/T`6lL8T6M0list node directory
E7p.d4B,P#L0查看本地节点
9QzY:qr0connect to db_alais user userid using password
3k3rp.?$N-u.H@0连接数据库
}9_a7YyFl.Yf0list tablespace51Testing软件测试网4HS k{S!^Mzi7`
查看表空间
@w;bz4?/z+w0describe table <表名>
Qh/O+LS,P{2Z0查看表结构51Testing软件测试网rTD ?l9V
fetch first 10 rows only 在sql语句中使用51Testing软件测试网yrAm4mt!u%O]
列出表中前10条记录

Cn9P8V.{ O9V'e051Testing软件测试网c*z4wF G8w/{3\

导出及导入,重点推荐51Testing软件测试网f0u u{#E%t@)S
export to .del(ixf) of del(ixf) (message log.message) select * from tablename
]"p*R.IQ:\0import from filename.del of del insert into tablename
Q |Gw t(] SE4~6B)h0可以导出为del或ixf格式

Wl7fU S0

3Vpr/W4KSJdT0可以使用以下方式删除表,不记录日志,比delete快
sl!g"R7j*L|C0import from /dev/null of del replace into test51Testing软件测试网^n,d/_Kn)Q1]'T

51Testing软件测试网v:aobXp7Cm*Y

有自增长列会导致导入失败,可以使用modified修饰符来修改导入选项
[k2kvQ ei$M_0import from filename.ixf of ixf modified by identityingore insert into tablename51Testing软件测试网~a:rq@'b
load from filename.ixf of ixf modified by identityoverride replace into tablename 'replace删除现有数据并导入51Testing软件测试网LG"[:|F5qxh D
load是直接将格式化的数据导入数据库中,所以速度要比import快

w?W._ i\rHmq0

&DHCo mZ1H0导出建表语句
JRm2P.f9P7|X0db2look51Testing软件测试网;b5hS.D'qu `
db2look -d dbname51Testing软件测试网[qY'At!W(dg-O
db2look -d test -a -e -l -o test.sql
C:V-J*u(],I.k*Q,x8j0导出数据库test下所有表的ddl语句
YZ)NmI}!G/O0db2look -d test -u user1-e -o db2look.sql51Testing软件测试网r?l#Q?(ut4kz
导出由用户user1创建的所有表的ddl语句51Testing软件测试网4rUX9i9KIL"l0` ?

51Testing软件测试网 fV a/}5r!S8ql2}


4u^4q`0l+L0db2move 数据库移动工具51Testing软件测试网'a(H7H%ES'E(a
db2move dbname action
M0E/`&K+?}4^}+`0action可以是import\export\copy\load
j [#L'yr ] b`^0db2 sample export -sn schemaname51Testing软件测试网0i j8C;P2p1q
db2 sample export -tn tablename
.v j],`;XT ?c0db2 sample import -io replace -u userid -p password  :-io后面可以是replace 、insert、 cretae等51Testing软件测试网AaVw:g7zm
db2 sample load -lo replace -u userid -p password  :lo是load的参数,后面只能是insert 或replace
d ~{5A\u7e0

f C7HF1{D]0

TAG:

 

评分:0

我来说两句

Open Toolbar