MYSQL relational database
http://www.go4expert.com/forums/showthread.php?t=13386
im following the article above and i am getting error at the first quoted code
#1049 - Unknown database 'library'
CREATE TABLE `library`.`books` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(开发者_如何学Python 150 ) NOT NULL ,
`author_id` INT UNSIGNED NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `author_id` )
) ENGINE = INNODB
the other one generates with no problem but this one, why?
Your table name is prepended with the database name "library". Probably your DB is named differently. If you're executing within the DB that you're using just remove the "library
." prefix.
CREATE TABLE `books` (
...
Remove the "library" part from the CREATE TABLE
statement. The other block in that article works because it doesn't reference "library".
Remove the library.
- just use what ever database you're using, ie
CREATE TABLE books (...
And while you're at it, remove all those unnecessary backticks - they are only required when using reserved words (which you should avoid like the plague anyway)
The table authors
will be created in your default/current database, here the database library
is to be used, but it hasn't been created. You should make a library
database.
CREATE DATABASE library
Using a differently named database, or removing library from the create table statement may cause problems further down the tutorial.
精彩评论