《BD2常用命令》由会员分享,可在线阅读,更多相关《BD2常用命令(5页珍藏版)》请在金锄头文库上搜索。
1、DB2的常用命令:1,列举出相应的 schema 下面的所有表。db2listtablesforschemaschemaname举例: db2listtablesforschemadb2admin2, 列举出当前数据库的目录。db2 list db directory举例:db2listdbdirectory3, DB2 自动增长主键方法generated always as identity(start with 1,increment by 1) 将一个字段指定为自增长型字段,放在数据类型后。举例:crate table students ( sno integer not null pr
2、imary key generated always as identity (start with 1, increment by 1), sname char(20), sname char(30)此时插入数据,然后查看结果,sno 自动增长 1.4, 数据的导入导出:export to E:name.txt of del select * from tableName导出举例 1:export to C:stInfo.ixf of ixf select * from students导出举例 2:导入举例 1:db2 import from E:name.txt of del insert into tableName导入举例 2:db2 import from E:name.ixf of ixf commitcount 5000 insert /create/replace intotableName5,查询表的主键:describe indexes for table .tablename show detail举例: