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
Federico Giust
8,157 PointsDatabase Foundations - Create Table movies error
Hi Guys,
I'm going through database foundations and I'm stuck in one of the code challenges.
The challenge is to create a table called movies with two columns title VARCHAR(255) and year INTEGER.
I'm using this statement which seems to be correct
CREATE TABLE IF NOT EXISTS movies ( title VARCHAR(255), year INTEGER);
But I keep getting this error
The types for title and year are incorrect. Use VARCHAR(255) and INTEGER respectively.
9 Answers
Christopher Hall
9,052 PointsI believe that you should be using the keyword INT instead of INTEGER. Such as:
CREATE TABLE IF NOT EXISTS movies ( title VARCHAR(255), year INT);
Federico Giust
8,157 PointsI tried both INT and INTEGER and still getting the same error
James Kennedy
20,755 Pointstry get rid of the "if not exists" I have noticed a few problems in these coding challenges not recognising optional parts. Try Create table movies(title varchar(255), Year Integer);
Federico Giust
8,157 PointsTried that already. When I remove the if not exists it throws an error saying that the table already exists.
James Kennedy
20,755 PointsIf this is your question: Create a table called "movies" with a VARCHAR column named "title" and an INTEGER column named "year". The title should be up to 255 characters long. I just tried the SQL statement create table movies (title varchar(255), year integer) and it worked first time?
Federico Giust
8,157 PointsNot sure what was going on but when I posted this I tried with
create table movies (title varchar(255), year integer); create table if not exists movies (title varchar(255), year integer); create table movies (title varchar(255), year int); create table if not exists movies (title varchar(255), year int);
The only difference was that I was trying with the datatypes in uppercase. I now tried again with the datatypes in lowercase and without the semicolon and it works now...
Julian Ptak
30,920 PointsDid anyone solve this? I'm stumbling on this question with a similar problem. Nothing I'm trying is working.
David Ruiz
4,802 PointsI think it's a mistake on their side, and they should do something about it, or at least post something here. It's really frustrating to have to learn on your own, so many times making mistakes and having to work out what you did wrong without on top of it have the code not pass when you typed it right. Anger!
Glen Sutton
3,809 PointsYep, I got stuck on that as well. It's really frustrating. Glad it is not only me.