Alter操作(修改列名,修改列数据类型,增加列,删除列,增加列且设为主键及对默认值操作)
生活随笔
收集整理的這篇文章主要介紹了
Alter操作(修改列名,修改列数据类型,增加列,删除列,增加列且设为主键及对默认值操作)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、mysql (增加列,刪除列,修改列;增加,刪除,修改列的默認值)
增加列,刪除列,修改列
1、修改列的數據類型
alter table patient modify column mood int2、修改列名
alter table patient change mood address VARCHAR(400)3、刪除列
alter table patient drop column mood4、增加列
alter table patient add column mood VARCHAR(400)5、增加列為主鍵
alter table patient add column id BIGINT not null PRIMARY KEY auto_increment first?6、將已有的列設置為主鍵
--將列名為id的字段設置為主鍵 alter table patient add primary key(id)7、(1)刪除已有的主鍵(drop直接刪除)
alter table patient drop primary key? ? ?(2)刪除已有的主鍵(列帶有auto_increment屬性)
--首先將自增條件去掉,再刪除主鍵 alter table patient modify column id int alter table patient drop primary keyfirst,after只作用于add
? 增加的列到第一列
alter table patient add column mood VARCHAR(400) first? 增加的列到指定列后面
alter table patient add column mood1 VARCHAR(400) after mood增加,刪除,修改列的默認值
1、修改字段默認值
alter table patient alter address set default 22、刪除字段默認值
alter table patient alter address drop default3、增加新列,帶默認值,在第一列
alter table patient add column mooood VARCHAR(400) default 21 first?4、查看表所有字段默認值
show COLUMNS from patient mysql二、oracle 修改列名、列的數據類型
1、修改列的數據類型
alter table patient modify(mood number(5,2))?2、修改列名
alter table patient rename column mood to address另:查看mysql安裝路徑:進入Navicat本地連接里面,新建查詢:
①select @@basedir
② show variables like "%char%";
首先進入mysql
輸入show variables like "%char%";
總結
以上是生活随笔為你收集整理的Alter操作(修改列名,修改列数据类型,增加列,删除列,增加列且设为主键及对默认值操作)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网络一大抄,无耻的网站
- 下一篇: 从头开始建立神经网络翻译及扩展