create table t_gasfee
(
id int primary key identity(1,1),
mouth smallint not null check(mouth>=1 and mouth<=12),
price int not null check(price>=0),
state varchar(1) not null default('0') ,
gassid int not null
)
我使用:
insert into t_gasfee values(1,12,'111')
怎么就报错:列名或所提供值的数目与表定义不匹配,default究竟怎么使用呀?
(
id int primary key identity(1,1),
mouth smallint not null check(mouth>=1 and mouth<=12),
price int not null check(price>=0),
state varchar(1) not null default('0') ,
gassid int not null
)
我使用:
insert into t_gasfee values(1,12,'111')
怎么就报错:列名或所提供值的数目与表定义不匹配,default究竟怎么使用呀?
改为insert into t_gasfee(mouth,price,gassid) Values(1,12,0,'111')的话state才会取默认值。
(
col1
,col2
,col3
)
select col1Value,col2Value,col3Value插入时指定列名,并且指定对应的值
insert into t_gasfee(price,month,state) values(1,12,'111