mysql 新增 修改 刪除 字段 sql語句

2021-09-21 13:37:59 字數 655 閱讀 5484

新增:

-- 在test_table 表的 valid_status 字段之後,新增乙個字段,設定對應的型別,長度,是否為null,預設值,注釋

alter table test_table add column `is_staff` tinyint(2) not null default '0' comment '是否是從業人員 0否 1是' after `valid_status`;

修改:

-- 修改乙個欄位的型別

alter table test_table modify test_value varchar(10) not null default '' comment '字段注釋';

-- 修改乙個欄位的名稱,此時要重新指定該字段的型別

alter table test_table change test_value_old test_value_new varchar(10) not null default '' comment '字段注釋';

刪除:

-- 刪除test_table表的 test_value欄位 

alter table test_table drop column test_value;

參考:

oracle 新增 修改 刪除字段

新增欄位的語法 alter table tablename add column datatype default value null not null 修改欄位的語法 alter table tablename modify column datatype default value null ...

Orcale新增 修改 刪除字段

一 新增字段 alert tableuser add username varchar2 255 char 設定欄位不為空,給出預設值 alert tableuser add username varchar2 255 char default 這是預設值 not null 二 修改字段 alter...

MySQL 新增 修改 刪除 字段 sql語句

在test table 表的 valid status 字段之後,新增乙個字段,設定對應的型別,長度,是否為null,預設值,注釋 alter table test table add column is staff tinyint 2 not null default 0 comment 是否是從...