十年網(wǎng)站開(kāi)發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無(wú)憂售后,網(wǎng)站問(wèn)題一站解決
發(fā)現(xiàn)clob類型比較特殊,和其他字段類型不同,不可以從其他字段類型直接轉(zhuǎn)換為clob(blob也一樣),可以通過(guò)long類型作為中間轉(zhuǎn)換的橋梁,即先將varchar2轉(zhuǎn)換為long,然后再將long轉(zhuǎn)換為clob,即可。
創(chuàng)新互聯(lián)建站專注于陳倉(cāng)企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè),電子商務(wù)商城網(wǎng)站建設(shè)。陳倉(cāng)網(wǎng)站建設(shè)公司,為陳倉(cāng)等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站制作,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)
SQL alter table test modify (loc long );
Table altered
SQL alter table test modify (loc clob );
Table altered
2、假設(shè)要修改字段有數(shù)據(jù),則可以使用以下兩種方法;
方法一:
alter table batchintfloadlog rename column resultinfo to resultinfo_temp;
alter table batchintfloadlog add resultinfo clob;
update batchintfloadlog set resultinfo=trim(resultinfo_temp);
alter table batchintfloadlog drop column resultinfo_temp;
方法二:
create table batchintfloadlog_temp ?as select * from batchintfloadlog where 1=2;?
alter table batchintfloadlog_temp modify (resultinfo long);?
alter table batchintfloadlog_temp modify (resultinfo clob);?
insert into batchintfloadlog_temp select * from batchintfloadlog;
drop table batchintfloadlog;?
rename batchintfloadlog_temp to batchintfloadlog;
語(yǔ)句:
alter table tableName rename column oldCName to newCName; -- 修改字段名
alter table tableName modify (cloumnName 數(shù)據(jù)類型); -- 修改數(shù)據(jù)類型
例如:
1、創(chuàng)建表:
CREATE TABLE Student(
id varchar2(32) primary key,
name varchar2(8) not null,
age number
);
2、修改字段名:
alter table Student rename column name to StuName;
3、修改數(shù)據(jù)類型:
alter table Student modify (id varchar2(64));
清醒時(shí)做事,糊涂時(shí)讀書,大怒時(shí)睡覺(jué),獨(dú)處時(shí)思考;做一個(gè)幸福的人,讀書,旅行,努力工作,關(guān)心身體和心情,成為最好的自己
用alter語(yǔ)句進(jìn)行修改。
語(yǔ)法:
alter
table
表名
modify
字段名
字段類型(字段長(zhǎng)度);說(shuō)明:如果是date等沒(méi)有長(zhǎng)度的類型,字段長(zhǎng)度部分可以省略。
如:目前test表屬性如下
要將name列的字段類型改為date類型,可用如下語(yǔ)句:
alter
table
test
mo...
首先方法是使用RENAME關(guān)鍵字:
修改字段名:alter table 表名 rename column 現(xiàn)列名 to 新列名;
修改表名:alter table 表名 rename to 新表名
增加字段語(yǔ)法:alter table tablename add (column datatype [default value][null/not null],….);
說(shuō)明:alter table 表名 add (字段名 字段類型 默認(rèn)值 是否為空);
例:alter table sf_users add (HeadPIC blob);
例:alter table?sf_users add (userName varchar2(30) default?'空' not null);
修改字段的語(yǔ)法:alter table tablename modify (column datatype [default value][null/not null],….);
說(shuō)明:alter table 表名 modify (字段名 字段類型?默認(rèn)值 是否為空);
例:alter table sf_InvoiceApply modify (BILLCODE number(4));
刪除字段的語(yǔ)法:alter table tablename drop (column);
說(shuō)明:alter table 表名 drop column 字段名;
例:alter table sf_users drop column HeadPIC;
字段的重命名:
說(shuō)明:alter table 表名 rename ?column? 列名 to 新列名?? (其中:column是關(guān)鍵字)
例:alter table sf_InvoiceApply rename column PIC to NEWPIC;
表的重命名:
說(shuō)明:alter table 表名 rename to? 新表名
例:alter table?sf_InvoiceApply rename to??sf_New_InvoiceApply;