我希望将数据插入到列中,如下所示:
INSERT INTO Song values (null, 'Truth of a Liar')
进入如下设置的表:
CREATE TABLE Song (id integer primary key, name varchar(255), count int not null default 0)
我收到以下错误:table Song has 3 columns but 2 values were supplied INSERT INTO Song2 values (null, 'Truth of a Liar')
我原本希望能够放入最后一栏,因为我偶尔可能需要输入count
值。我知道我可以像这样明确地填充列:
INSERT INTO Song(id, name) values (null, 'msdads')
但我希望有另一种选择。
是否有另一种方法将INSERT
数据导入表中,使用了一些默认值和一些设定值?
答案 0 :(得分:0)
你可以这样做:
INSERT INTO Song values (null, 'Truth of a Liar',0)
当您不想为最后一列插入任何内容时。如果要偶尔插入值,可以使用该值而不是0。