Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post

    creating a tabel in 5.5

    I have just started using sql but when i try to use this code it does not work.
    Code:
    CREATE TABLE users
    (
       id INT IDENTITY(1,1),
       username VARCHAR(20) UNIQUE,
      password VARCHAR(20)  ,
       email VARCHAR(50)
    );
    I just dont understand how to make a tabel in 5.5 m using the command line client.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,636 Times in 4,598 Posts
    IDENTITY is SQL Server, not MySQL.

    Read the docs: http://dev.mysql.com/doc/refman/5.5/...ate-table.html

    Code:
    CREATE TABLE users 
    (
        id INT AUTO_INCREMENT PRIMARY KEY,
        username VARCHAR(20) UNIQUE,
        password VARCHAR(20),
        email VARCHAR(50)
    );
    NOTE: In MySQL, the AUTO_INCREMENT field *must* be a key, so it's common to make it the PRIMARY KEY, though it doesn't have to be. But if you will use it as a foreign key in other tables, then making it PRIMARY is best practice.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Your link does not work. and was identity the only thing that was wrong?
    Last edited by sherlockturtle; 10-15-2011 at 12:20 AM.

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by sherlockturtle View Post
    Your link does not work. and was identity the only thing that was wrong?
    He gave you the SQL statement that would work you can compare that with yours to see the differences. He changed the identity to auto increment and made it the primary key.
    OracleGuy

  • #5
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    thanks both of you.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,636 Times in 4,598 Posts
    I just retested that link. It worked fine.

    But just in case, here it is in plain text:

    http://dev.mysql.com/doc/refman/5.5/en/create-table.html
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •