troubleshooting Question

sql populate data script for primary key values

Avatar of tsunamicisity
tsunamicisity asked on
IBM System iDB2Java App Servers
6 Comments1 Solution614 ViewsLast Modified:
ok so I have created a table  that has a primary key of addressID.  When I run a script to populate some data in there how do I show it to be autoincreminting?

Look at the INSERT INTO script below and you will notice that there is a "1" or "2" being dumped into the addressID field.  This works but I would rather has a way of that just automatically just being filled in.  I'm guessing that I need to run a script that tells that colum to be auto incrementing... Then what do I pu in place of the addressID "1" or "2" in the populate script?

create table address
(      addressID                  int                  not null,
      addressLine1            char(25)      not null,
      addressLine2            char(25)      not null,
      city                        char(25)      not null,
      stateAbv                  char(2)            not null,
      zip                              int                  not null,
      phone                        char(25)      not null,
      primary key(addressID)

INSERT INTO Address (addressID, addressLine1, addressLine2, city, stateabv, zip, phone) VALUES
('1', '7586 Whistlewood SW', ' ', 'Byron Center', 'MI', '49315', '6165558888'),
('2', '7584 Whistlewood SW', ' ', 'Byron Center', 'MI', '49315', '6165559999'),
('3','90 Port Sheldon Rd SW', ' ', 'Grandville', 'MI', '49418', '6165557777'),
('4','92 Port Sheldon Rd SW', ' ', 'Grandville', 'MI', '49418', '6165556666'),
('5','319 Perry', 'Suite A', 'Wyoming', 'MI', '49419', '6165555555'),
('6','319 Perry', 'Suite B', 'Wyoming', 'MI', '49419', '6165554444'),
('7','319 Perry', 'Suite C', 'Wyoming', 'MI', '49419', '6165553333'),
('8','319 Perry', 'Suite D', 'Wyoming', 'MI', '49419', '6165551111')


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros