MySQL中表的列結構的修改操作

2022-05-14 15:34:36 字數 809 閱讀 7957

首先建立乙個用於測試的表test_table

drop table if exists test_table;

create table `test_table` (

`id` int(11) default null,

`name` varchar(20) default null,

`age` int(11) default null,

`brief` varchar(100) default null

);

在表的最後插入一列:

alter table test_table add column test_column1 varchar(20);
在表的某一列後插入一列:

alter table test_table add column test_column2 varchar(20) after name;
在表的開頭插入一列:

alter table test_table add column test_column3 varchar(20) first;
刪除某一列:

alter table test_table drop column test_column1;
修改某一列的型別:

alter table test_table modify column test_column2 integer;

mysql修改列的型別

mysql alter table 表名 modify column 欄位名 型別 例如 資料庫中address表 city欄位是varchar 30 修改型別可以用 謹慎修改型別,可能會導致原有資料出錯 mysql alter table address modify column city ch...

修改ORALCE中表的字段

如何修改oracle資料庫中表的結構 欄位的名稱 長 型別 是否為空 改型別 長度 是否為空 alter table mytable modify mycol varchar2 20 not null 要修改型別,字段必須是空的 要修改長度,如果欄位是空的,完全可以改,如果欄位不空,則只能增加長度,...

MySQL中表的操作

語法 create table table name field1 datatype,field2 datatype,field3 datatype character set 字符集 collate 校驗規則 engine 儲存引擎 說明 create table class major varc...