Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Problem with Sql code

  • 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, Registered Users 2 Posts: 68,173 ✭✭✭✭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