MySQL Workbench Error 1064 when creating table
I am trying to use MySQL Workbench 8.0.3 with MariaDB but I get the following error:
Executing:
CREATE TABLE `mydb`.`customer` (
`ID` INT UNIQUE UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`Street` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
`City` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
PRIMARY KEY (`ID`));
ERROR 1064: You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARC' at line 2
SQL Statement:
CREATE TABLE `mydb`.`customer` (
`ID` INT UNIQUE UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`Street` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
`City` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
PRIMARY KEY (`ID`))
Operation failed: There was an error while applying the SQL script to the database.
The code you see above has been generated using the "Create Table" Workbench feature.
Same error when using PHP/mySQLli
EDIT SOLVED:
ID INT(10)
not
ID INT
mysql sql mariadb
add a comment |
I am trying to use MySQL Workbench 8.0.3 with MariaDB but I get the following error:
Executing:
CREATE TABLE `mydb`.`customer` (
`ID` INT UNIQUE UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`Street` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
`City` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
PRIMARY KEY (`ID`));
ERROR 1064: You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARC' at line 2
SQL Statement:
CREATE TABLE `mydb`.`customer` (
`ID` INT UNIQUE UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`Street` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
`City` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
PRIMARY KEY (`ID`))
Operation failed: There was an error while applying the SQL script to the database.
The code you see above has been generated using the "Create Table" Workbench feature.
Same error when using PHP/mySQLli
EDIT SOLVED:
ID INT(10)
not
ID INT
mysql sql mariadb
PK is by default Unique; it does not make sense to define unique constraint on a already defined primary key
– Madhur Bhaiya
Nov 8 '18 at 19:59
add a comment |
I am trying to use MySQL Workbench 8.0.3 with MariaDB but I get the following error:
Executing:
CREATE TABLE `mydb`.`customer` (
`ID` INT UNIQUE UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`Street` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
`City` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
PRIMARY KEY (`ID`));
ERROR 1064: You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARC' at line 2
SQL Statement:
CREATE TABLE `mydb`.`customer` (
`ID` INT UNIQUE UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`Street` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
`City` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
PRIMARY KEY (`ID`))
Operation failed: There was an error while applying the SQL script to the database.
The code you see above has been generated using the "Create Table" Workbench feature.
Same error when using PHP/mySQLli
EDIT SOLVED:
ID INT(10)
not
ID INT
mysql sql mariadb
I am trying to use MySQL Workbench 8.0.3 with MariaDB but I get the following error:
Executing:
CREATE TABLE `mydb`.`customer` (
`ID` INT UNIQUE UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`Street` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
`City` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
PRIMARY KEY (`ID`));
ERROR 1064: You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARC' at line 2
SQL Statement:
CREATE TABLE `mydb`.`customer` (
`ID` INT UNIQUE UNSIGNED NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Email` VARCHAR(255) CHARACTER SET 'utf8' NOT NULL,
`Street` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
`City` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL,
PRIMARY KEY (`ID`))
Operation failed: There was an error while applying the SQL script to the database.
The code you see above has been generated using the "Create Table" Workbench feature.
Same error when using PHP/mySQLli
EDIT SOLVED:
ID INT(10)
not
ID INT
mysql sql mariadb
mysql sql mariadb
edited Nov 11 '18 at 12:53
Zoe
11.3k73976
11.3k73976
asked Nov 8 '18 at 19:48
user10570640
PK is by default Unique; it does not make sense to define unique constraint on a already defined primary key
– Madhur Bhaiya
Nov 8 '18 at 19:59
add a comment |
PK is by default Unique; it does not make sense to define unique constraint on a already defined primary key
– Madhur Bhaiya
Nov 8 '18 at 19:59
PK is by default Unique; it does not make sense to define unique constraint on a already defined primary key
– Madhur Bhaiya
Nov 8 '18 at 19:59
PK is by default Unique; it does not make sense to define unique constraint on a already defined primary key
– Madhur Bhaiya
Nov 8 '18 at 19:59
add a comment |
2 Answers
2
active
oldest
votes
UNSIGNED
and INT
go together, so this works:
`ID` INT UNSIGNED UNIQUE NOT NULL AUTO_INCREMENT,
This is shorter:
`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
A primary key is already non-NULL
and unique
. There is no need to declare those properties twice.
add a comment |
I solved it by using int(10) instead of int
ID INT(10)
not
ID INT
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53215122%2fmysql-workbench-error-1064-when-creating-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
UNSIGNED
and INT
go together, so this works:
`ID` INT UNSIGNED UNIQUE NOT NULL AUTO_INCREMENT,
This is shorter:
`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
A primary key is already non-NULL
and unique
. There is no need to declare those properties twice.
add a comment |
UNSIGNED
and INT
go together, so this works:
`ID` INT UNSIGNED UNIQUE NOT NULL AUTO_INCREMENT,
This is shorter:
`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
A primary key is already non-NULL
and unique
. There is no need to declare those properties twice.
add a comment |
UNSIGNED
and INT
go together, so this works:
`ID` INT UNSIGNED UNIQUE NOT NULL AUTO_INCREMENT,
This is shorter:
`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
A primary key is already non-NULL
and unique
. There is no need to declare those properties twice.
UNSIGNED
and INT
go together, so this works:
`ID` INT UNSIGNED UNIQUE NOT NULL AUTO_INCREMENT,
This is shorter:
`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
A primary key is already non-NULL
and unique
. There is no need to declare those properties twice.
answered Nov 8 '18 at 19:57
Gordon LinoffGordon Linoff
763k35296400
763k35296400
add a comment |
add a comment |
I solved it by using int(10) instead of int
ID INT(10)
not
ID INT
add a comment |
I solved it by using int(10) instead of int
ID INT(10)
not
ID INT
add a comment |
I solved it by using int(10) instead of int
ID INT(10)
not
ID INT
I solved it by using int(10) instead of int
ID INT(10)
not
ID INT
answered Nov 13 '18 at 1:33
user10570640
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53215122%2fmysql-workbench-error-1064-when-creating-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
PK is by default Unique; it does not make sense to define unique constraint on a already defined primary key
– Madhur Bhaiya
Nov 8 '18 at 19:59