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 trialBob McKay
5,814 PointsBaffled by MySQL Create Table
Hi all,
I'm sure I'm doing something stupid (or not doing something smart!) but I'm baffled by a really simple step in the MySQL foundation course - I'm being asked to do the following:
Create a genres table called "t_genres" with an auto incrementing primary key called "pk_id" and a unique column called "uk_name" that can't be null. The "uk_name" is a varchar of up to 45 characters.
I am entering this:
CREATE TABLE t_genres (pk_id INTEGER AUTO_INCREMENT PRIMARY KEY, uk_name VARCHAR(45) NOT NULL)
But I'm getting this error returned (and I'm failing):
43df43e0-46c7-4f61-abf4-8a5d68595ae4.rb:38:in eval': wrong number of arguments (at least 1) (ArgumentError)
from (eval):11:in
<main>'
from 43df43e0-46c7-4f61-abf4-8a5d68595ae4.rb:38:in eval'
from 43df43e0-46c7-4f61-abf4-8a5d68595ae4.rb:38:in
<main>'
Any ideas? Been banging my head against it for a while now!
Thanks
Bob
3 Answers
Bob McKay
5,814 PointsSod it - completely missed the 'unique' specification.
Véronique Bellamy
20,810 PointsI don't see anything wrong with your code but I did spruce it up a bit. Maybe try this?
CREATE TABLE t_genres (
pk_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
uk_name VARCHAR(45) NOT NULL
);
Let me know if this works out for you. :)
Bob McKay
5,814 PointsYes all sorted thanks Jessica, I was missing 'UNIQUE' from the SQL (I just didn't see it in the instructions - my coding was ok, it was my English comprehension at fault! :-D
Véronique Bellamy
20,810 PointsC'est la vie. ;)
Good luck in your adventures.
Véronique Bellamy
20,810 PointsVéronique Bellamy
20,810 PointsIs your issue resolved, hun?