MySQL Workbench Error 1064 when creating table












0















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









share|improve this question

























  • 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
















0















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









share|improve this question

























  • 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














0












0








0








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









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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












2 Answers
2






active

oldest

votes


















1














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.






share|improve this answer































    0














    I solved it by using int(10) instead of int



    ID INT(10)


    not



    ID INT





    share|improve this answer























      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
      });


      }
      });














      draft saved

      draft discarded


















      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









      1














      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.






      share|improve this answer




























        1














        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.






        share|improve this answer


























          1












          1








          1







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 '18 at 19:57









          Gordon LinoffGordon Linoff

          763k35296400




          763k35296400

























              0














              I solved it by using int(10) instead of int



              ID INT(10)


              not



              ID INT





              share|improve this answer




























                0














                I solved it by using int(10) instead of int



                ID INT(10)


                not



                ID INT





                share|improve this answer


























                  0












                  0








                  0







                  I solved it by using int(10) instead of int



                  ID INT(10)


                  not



                  ID INT





                  share|improve this answer













                  I solved it by using int(10) instead of int



                  ID INT(10)


                  not



                  ID INT






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 1:33







                  user10570640





































                      draft saved

                      draft discarded




















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Florida Star v. B. J. F.

                      Danny Elfman

                      Lugert, Oklahoma