首先看建表語句 ,其中紅色語句為自動(dòng)增長(zhǎng)列的實(shí)現(xiàn),更詳細(xì)內(nèi)容請(qǐng)參考apache的derby用戶手冊(cè):
create table cutCustomers (
id int not null PRIMARY KEYGENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
name varchar(10),
tell varchar(20),
createDate varchar(20)
)
接著,執(zhí)行插入語句:
insert into cutCustomers values('阿亮','138264852','2010年10月2日')
報(bào)錯(cuò):ERROR 42802: The number of values assigned is not the same as the number of specified or implied columns.
費(fèi)老大勁在百度google上搜索,無解。數(shù)據(jù)類型應(yīng)該也沒問題。結(jié)果嘗試單列插入,以排除其他列帶來的問題。
insert into cutCustomers (name) values('阿亮')
結(jié)果:插入成功
思考:其他列沒有數(shù)據(jù)類型問題,難道是需要指定列名?
指定列名,嘗試執(zhí)行:
insert into cutCustomers (name,tell,createDate) values('阿亮','138264852','2010年10月2日')
成功!!!!!!!!!!!!
我那個(gè)汗啊!
學(xué)軟件開發(fā),到蜂鳥科技!
超強(qiáng)的師資力量 、完善的課程體系 、超低的培訓(xùn)價(jià)格 、真實(shí)的企業(yè)項(xiàng)目。
網(wǎng)址:
電話:
鄭州軟件開發(fā)興趣小組群: