新增字段:
alter table 表名 add column 欄位名 字段型別 default '預設值';
例:alter table user add column user_age integer default 0
刪除字段:
altertable
表名 dropcolumn
欄位名;
修改現有字段命名:
alter table 表名 rename column
欄位名 to 新欄位名
修改現有字段預設值:
alter table 表名 alter column 欄位名 set default '預設值'
刪除現有字段預設值:
alter table 表名 alter
column
欄位名 set drop default
將字段改為非空:
alter table 表名 alter column 欄位名 set not null
修改db2表結構後,db2會自動鎖表,只允許查詢不允許增刪改
使用該sql語句即可避免,作用==重構表結構,對錶結構有改動後執行該sql即可
call sysproc.admin_cmd('reorg table 表名')
DB2資料庫相關操作
自增字段的建立 start with 1 increment by 1 cache 20 no cycle no order 設定自增序列從20001開始 alter sequence linkage seq restart with 20001 使用自增字段 插入一條資料insert into l...
DB2資料庫新增 更改字段
db2 表基本新增字段操作 1.新增字段 alter table table name add column name column type 2.更改字段型別 alter table table name alter column column name setdata type column t...
DB2 命令 資料庫操作
標籤 空格分隔 db2例項 db2授權 資料庫 資料庫名稱 database name lqr 使用者名稱 user name lqr 檢視表空間名稱 db2 list tablespaces show detail 表空間名稱 需要大寫 tablesapce name userspace1 例項或...