If you just don't want a primary key in your major data tables, then create
a table for the express purpose of generating primary keys that uses
auto_increment.  Something like:

create table myseq (x   serial;)


Each time you need a new key, get the next value from that table.  It would
be more like an Oracle sequence that an auto_increment.

On Mon, Apr 27, 2009 at 11:59 PM, yuan edit <edit.y...@gmail.com> wrote:

> I have a shopping cart table like this:
>
> CREATE TABLE shopping_cart(
> id VARCHAR(20) NOT NULL,
> product_id INT NOT NULL,
> product_quantity INT NOT NULL,
> ...
> ...
> user_id INT NOT NULL,
> current_timestamp TIMESTAMP,
> primary key (id)
> );
>
> I will not use auto_increment
>
> Is there other way to  generate unique primary key in MySQL?
>
> Thank you
>



-- 
Jim Lyons
Web developer / Database administrator
http://www.weblyons.com

Reply via email to