Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Problem with Sql code

Options
  • 22-02-2005 11:42pm
    #1
    Closed Accounts Posts: 1,152 ✭✭✭


    Hi, im studying for exams at the moment and have come across the following SQL code where there is apparnetly a problem. I can't spot it myself, can someone help me out?
       Create table mydata
         (id number(3) primary key,
          name char(10),
          address char(100));
    
       create sequence seq1
       increment by 1
       start with 1
       maxvalue 3000
       cycle;
    
      insert into mydata values
       (seq1.nextval, 'FRED', 'Somewhere in Cork');
    

    Thanks


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    What's the error you get?

    First statement, there's no such data type as "number" (At least not in MySQL).


  • Registered Users Posts: 1,186 ✭✭✭davej


    The problem is the sequence is set to cycle, but id is a primary key. Big no no

    davej


  • Registered Users Posts: 2,781 ✭✭✭amen


    or maybe
    number(3)
    
    when means that the max you can hold is a 3 digit number but
    you have said the max of seq1 is 3000 which is a 4 digit number
    what sql language is this ?


Advertisement