set, 不能加,只能先取出來,加好以后再update回去.set 內(nèi)部是一個64位的整數(shù),用位來表示的,所以就只能最大64
創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比亭湖網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式亭湖網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋亭湖地區(qū)。費用合理售后完善,十多年實體公司更值得信賴。
alter table teacher_tbl drop column emp_class;//刪除字段名
alter table teacher_tbl change emp_id tea_id varchar(10) ,
change emp_name tea_name varchar(10),
change emp_sex tea_sex char(4),
change emp_phone tea_phone int(40);//修改字段名稱
ALTER TABLE:添加,修改,刪除表的列,約束等表的定義。
查看列:desc 表名;
修改表名:alter table t_book rename to bbb;
添加列:alter table 表名 add column 列名 varchar(30);
刪除列:alter table 表名 drop column 列名;
修改列名MySQL: alter table bbb change nnnnn hh int;
修改列名SQLServer:exec sp_rename't_student.name','nn','column';
修改列名Oracle:lter table bbb rename column nnnnn to hh int;
修改列屬性:alter table t_book modify name varchar(22);
sp_rename:SQLServer 內(nèi)置的存儲過程,用與修改表的定義。
刪除語句:delete from fatie where id not in(select t.id1 from ( (select max(a.id) id1 from fatie a group by a.name)as t));留下的是各組id號最大的,如果留的是最小的話換成min(a.id)就行了
如果沒有加上一個中間表t,即這句話 select t.id from去掉直接寫成delete from fatie where id not in(select max(id) a.id1 from fatie a group by a.name);mysql會提示錯誤:You can't specify target table 'fatie' for update in FROM clause (不能先select出同一表中的某些值,再update這個表(在同一語句中)。
參考資料
CSDN.CSDN[引用時間2018-1-9]
若是修改列屬性的話,
alter
table
user
modify
column
id
int;
在這里指定id的新類型為int,其他的如自增,自然是刪掉了。
或者使用
alter
table
user
change
id
id
int;
若是刪除表中列的話,
alter
table
user
drop
id;
這就可以了。
第一:對的,mysql會報錯無信息,不執(zhí)行;
第二:mysql_insert_id返回最后插入值的ID 值
1、首先新建一張表結(jié)構(gòu)。
2、select * from?t_temp_test 查看下這張表已經(jīng)建好在數(shù)據(jù)庫里面了。
3、查看該t_temp_test表結(jié)構(gòu) ?sp_help t_temp_test,可以看到字段column_b 的默認值定義為空,默認屬性是DF__t_temp_te__colum__19DA45DB。
4、修改表的默認值先要把表的默認屬性刪除了才能修改,刪除表的默認屬性。
5、刪除之后再執(zhí)行sp_help t_temp_test,這個時候默認值屬性已經(jīng)被刪除了的。
6、然后再重新給字段新加上默認屬性alter table t_temp_test add constraint DF__t_temp_te__colum__19DA45DB DEFAULT (('123')) for column_b。
7、執(zhí)行完畢再查詢表結(jié)構(gòu)sp_help t_temp_test可以看到表的默認值已經(jīng)被更改為字符串‘123’。
網(wǎng)站題目:mysql怎么刪除屬性值,mysql刪除字段值
URL分享:http://chinadenli.net/article36/heeisg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、關(guān)鍵詞優(yōu)化、網(wǎng)站收錄、動態(tài)網(wǎng)站、全網(wǎng)營銷推廣、服務(wù)器托管
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)