I’m looking to insert data into a column like so:
INSERT INTO Song values (null, 'Truth of a Liar')
into a table set up like this:
CREATE TABLE Song (id integer primary key, name varchar(255), count int not null default 0)
and I get the following error: table Song has 3 columns but 2 values were supplied INSERT INTO Song2 values (null, 'Truth of a Liar')
I was expecting be able to not put in the last column because I occasionally might have to put in the count value. I’m aware that I could explicitly fill the columns like so:
INSERT INTO Song(id, name) values (null, 'msdads')
but I was hoping for an alternative.
Is there another way to INSERT data into tables, using some default values and some set values?
You could do:
when you do not want to insert anything for last column. When you want to occasionally insert a value, you can use that value instead of 0.