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
aaron durber
13,400 Pointsmysql create new table query
hey guys could I please have some advice on this sql query please, instead of creating the shirts for mike database I'm creating my own for my website can you please let me know if this is ok?
CREATE DATABASE dyscaculia DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE dyscaculia;
CREATE TABLE IF NOT EXISTS users (
Firstname varchar(1) DEFAULT NULL
Lastname varchar(1) DEFAULT NULL
Username varchar(1) DEFAULT NULl
Email decimal(1) DEFAULT NULL,
ConfirmEmaill varchar(1) DEFAULT NULL
Password varchar(1) DEFAULT NULL
PasswordEmaill varchar(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2 Answers
Nathan F.
30,773 PointsIt looks okay except for the varchar values. A varchar(1) will only allocate space up to one character. And email would need to be a type other than decimal.
aaron durber
13,400 Pointshi nathan thanks for your comments they are much appreciated however i've changed the sql query slightly
to this:
/* Table dyscaculia */
CREATE TABLE dyscaculia_DB.dyscaculia (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
`last_name` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
`user_name` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
`confirm_user_name` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
`pass_word` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
`confirm_pass_word` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
`e_mail` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
`user_type` INT(2) NOT NULL DEFAULT 7,
PRIMARY KEY (`ID`)
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci
when i run the query the following error message comes up- #1049 - Unknown database 'dyscaculia_db'