1.DB2ADMIN“ 没有执行操作 “CREATE SCHEMA“ 的特权
db2 GRANT DBADM ON DATABASE to user db2admin
2.备份数据库的表
--复制表结构
create table table_name_new as (select * from table_name_old) definition only;
--插入数据
insert into table_name_new (select * from table_name_old);
3.删除一个表字段后无法删除表且出现DB2 sqlstate 57016 原因码 "7"错误
CALL SYSPROC.ADMIN_CMD('reorg table T_AISINO_INVOICE_HX')
T_AISINO_INVOICE_HX为表名
4.如何验证windows安装db2安装成功
https://blog.csdn.net/weixin_44137201/article/details/107348326
5.db2创建表失败,提示字节长度太大了?
解决方法是新建一个大一点的表空间,然后在这个表空间建表。
//查看表空间
select
substr(tbsp_name,1,20) as 表空间名称,
substr(tbsp_content_type,1,10) as 表空间类型,
sum(tbsp_total_size_kb)/1024/1024 as 表空间总大小(G),
sum(tbsp_used_size_kb)/1024/1024 as 已经使用的表空间大小(G),
sum(tbsp_free_size_kb)/1024/1024 as 剩余表空间大小(G),
tbsp_page_size AS 页大小
from SYSIBMADM.TBSP_UTILIZATION
group by
tbsp_name,
tbsp_content_type,
tbsp_page_size
order by 3 desc
//1.创建表空间
create BUFFERPOOL <缓冲池名称> SIZE 5000 PAGESIZE 32K;
CREATE TABLESPACE <表空间名称> PAGESIZE 32K BUFFERPOOL <缓存池名称>
//2.设置表空间自动增长
ALTER TABLESPACE <表空间民称> AUTORESIZE YES;
6.设置字段自增
Alter table <table name> alter column <column name> set generated always as identity (start with 1,increment by 1)
7.查看表所在的表空间:
select tabname,tbspace from syscat.tables where tabname = ‘表名’;–表名大写
8.查看表的索引:
select * from syscat.indexes where tabname = ‘表名’;–表名大写
9.创建表时指定表空间
CREATE TABLE "DB2ADMIN"."TEST"
(
T1 VARCHAR(20)
)
IN "O_TBS"
INDEX IN "O_IDX_TBS";
创建表TEST,放在表空间O_TBS内,同时,TEST的索引放在O_IDX_TBS表空间内
10.db2查询sql中添加order by时出现错误,原因是系统临时表空间不足,执行一下语句
CREATE BUFFERPOOL BP32K pagesize 32K;
CREATE SYSTEM TEMPORARY TABLESPACE STB_32 PAGESIZE 32K BUFFERPOOL BP32K;