天天看點

【資料庫】修改表結構

一、修改字段預設值

alter table 表名 drop constraint 限制名字   ------說明:删除表的字段的原有限制

alter table 表名 add constraint 限制名字 DEFAULT 預設值 for 字段名稱 -------說明:添加一個表的字段的限制并指定預設值

二、修改字段名:

alter table 表名 rename column A to B

三、修改字段類型:

alter table 表名 alter column UnitPrice decimal(18, 4) not null 

alter table 表名  modify  字段名  char(32)  限制  COMMENT 備注

alter table remit_domestic_sub_record  modify account_no  char(32)  null default null COMMENT '賬戶編号'

三、修改增加字段:

alter table 表名 ADD 字段 類型 NOT NULL Default 0