Re: auto-increment tony wrote:
> I'm trying to understand how this works.
>
> insert into table_a (opt_id, opt_val_id)
> values (1,2)
>
> The table def is :
>
> product_id int notnull
> opt_id int notnull
> opt_val_id int notnull
>
> When I execute this the product_id auto-increments. There is no
> trigger or stored proc that I can see. How does the auto-inc occur?
Try
show create table table_a;
I bet you'll see something like
CREATE TABLE `table_a` (
`product_id` int(11) NOT NULL auto_increment,
`opt_id` int(11) NOT NULL default '',
`opt_val_id` int(11) NOT NULL default '',
PRIMARY KEY (`product_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
So, because of the "auto_increment" in the `product_id` definition, when
you insert a row without a specific product_id, the database itself will
pick a value for it.
--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot |