简体   繁体   中英

#1075 MySQL Error

So i am just a beginner in all this php stuff. I know just the basics, and when i setting up the settings for my new table, I met the problem #1075. Before, i created one, almost similar to this one, and i don't see the differenc. Can you say me where is the problem and explain what is happening?

CREATE TABLE `try`.`testing` ( `id` INT NOT NULL AUTO_INCREMENT , `date` DATE NOT NULL , `text_1` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , `text_2` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ) ENGINE = MyISAM;

here is the code of my SQL Preview. I use phpMyAdmin, obviously. Please, help me. Thank, you)

Try this

CREATE TABLE `testing` (
  `id` INT NOT NULL AUTO_INCREMENT, 
  `date` DATE NOT NULL, 
  `text_1` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 
  `text_2` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE = MYISAM ;

You have to declare your AUTO_INCREMENT field as a primary key or a key . So you have to add PRIMARY KEY (id) or KEY (id) to your CREATE TABLE statement:

CREATE TABLE `try`.`testing` ( 
`id` INT NOT NULL AUTO_INCREMENT, 
`date` DATE NOT NULL , 
`text_1` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , 
`text_2` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) -- as primary key
KEY (`id`) -- or as key
) ENGINE = MyISAM;

Please also check:

https://stackoverflow.com/a/8114994/3647441

https://stackoverflow.com/a/14087703/3647441

For an autoincrement field you should have some sort of index associated with it. eg: primary key which is missing

Try This.

CREATE TABLE `try`.`testing` ( 
`id` INT NOT NULL AUTO_INCREMENT, 
`date` DATE NOT NULL , 
`text_1` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , 
`text_2` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
KEY (`id`) 
) ENGINE = MyISAM;

https://dev.mysql.com/doc/refman/5.6/en/example-auto-increment.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM