Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Access 2003: Auto Increment Field

Discussion in 'Information Technology' started by MJMP, Nov 3, 2005.

  1. MJMP

    MJMP
    Expand Collapse
    Guest

    I am starting to learn about SQL and had a question about the INSERT INTO
    statment.

    For the sake of discussion, there is table titled SONG. It has three
    attributes: SongID (primary key, increment), SongName, and AlbumID. Note
    that the last SongID in the table is 12.

    And if we were interested in writing an INSERT INTO statement that adds a
    song called "Wanna Rock" with album ID of 4 into the table, we used:

    INSERT INTO SONG
    VALUES (13, 'Wanna Rock', 4)

    Will that automatically insert 13 into the SongID field if the field is set
    to increment? And what if there used to be a SongID of 14 and then a DELETE
    query was run, if you where to run an INSERT query, will Access use 14 or
    will it assign the next number of 15?

    I hope that made sense!
     
  2. Loading...


  3. Larry

    Larry
    Expand Collapse
    Guest

    Re: Access 2003: Auto Increment Field

    You asked: Will that automatically insert 13 into the SongID field if
    the field is set to increment? Yes, if by increment you mean the SongID
    field is set to "auto number." You should be able to write your SQL
    query as:

    INSERT INTO SONG (SongName, AlbumID)
    VALUES ('Wanna Rock', 4)

    and let Access do the numbering for you.
     

Share This Page