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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Problem with Sql code

  • 22-02-2005 10: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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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