Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Modifying Data with SQL Adding Data to a Database Adding Data With SQL

When inserting a row, do I have to write NULL for the id to make use of the autoincrementing property?

INSERT INTO <table> VALUES(NULL, "bla", "bla");

here, the first entry is autoincrementing so I want to make use of that. Do I have to assign it the NULL value?

1 Answer

Just to add that in case you don't specify the column names, then you need to enter NULL for the id column.

So while this passes ok

INSERT INTO actors (name) VALUES ("John Smith");

This doesn't

INSERT INTO actors VALUES ("John Smith");

and you would have to use NULL like this

INSERT INTO actors VALUES (NULL, "John Smith");