[thelist] Auto Increment in database - a goofy question I am sure

Schoolcraft, Jeffrey JSchoolcraft at SytexInc.com
Thu Apr 18 07:18:01 CDT 2002


In mysql the definition for an AI index would look like:

	id int not null auto_increment

Essentially what this does is builds a primary key for the database.
Auto_increment indexes are traditionally integers.  But this is a
non-updateable key.  If you had a table that looked like this:

	create table foo (
		id int not null auto_increment,
		name varchar(50),
		phone varchar(11),
		primary key (id)
	);

You would make an insert statements like this:
	insert into foo (name, phone) values ('john doe', '555-555-1212');
	insert into foo (name, phone) values ('jane doe', '555-212-5555');

And your selects would look like:
	select * from database;
	1, john doe, 555-555-1212
	2, jane doe, 555-212-5555

It auto increments your id.

Hopefully this is what you're looking for.


> -----Original Message-----
> From: Jay Blanchard [mailto:jay.blanchard at niicommunications.com]
> Sent: Thursday, April 18, 2002 8:03 AM
> To: thelist at lists.evolt.org
> Subject: RE: [thelist] Auto Increment in database - a goofy
> question I am sure
>
>
> [snip]
> jay, what's an AI index?
> [/snip]
>
> auto increment index
>
> :)
>
> Jay
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !



More information about the thelist mailing list