Jump to content

Emptying MySQL DB tables


markscarts
 Share

Recommended Posts

I want to empty my inventory table and cats_idx on one of my sites. The categories will remain the same. I assume the best way to empty the inventory table is:

TRUNCATE TABLE CubeCart_inventory;

If I use this command, will it empty the auto_increment counts as well as emptying the records from the table? IOW, after truncating this table, when I re-populate it, will the record id begin at 1?

Thanks fo any information.

Link to comment
Share on other sites

Guest EverythingWeb

Hi Mark,

The auto-increment value is stored as one of the properties of the tables. For example, here is a dump of one of our test stores' inventory tables:

CREATE TABLE `306test_CubeCart_inventory` (

  `productId` int(11) NOT NULL auto_increment,

  `productCode` varchar(60) NOT NULL default '',

  `quantity` int(16) NOT NULL default '1',

  `description` text NOT NULL,

  `image` varchar(250) NOT NULL default '',

  `noImages` int(11) NOT NULL default '0',

  `price` decimal(30,2) NOT NULL default '0.00',

  `name` varchar(250) NOT NULL default '0',

  `cat_id` int(16) NOT NULL default '0',

  `popularity` bigint(64) NOT NULL default '0',

  `sale_price` decimal(30,2) NOT NULL default '0.00',

  `stock_level` int(11) default '0',

  `useStockLevel` int(11) default '1',

  `digital` int(11) NOT NULL default '0',

  `digitalDir` varchar(255) default NULL,

  `prodWeight` decimal(10,3) default NULL,

  `taxType` int(11) default NULL,

  `showFeatured` int(11) NOT NULL default '1',

  PRIMARY KEY  (`productId`)

) TYPE=MyISAM AUTO_INCREMENT=3;

What I would suggest, AFTER BACKING UP, is to export the structure of the table, edit the bottom line to read: 'AUTO_INCREMENT=1' and re-create the table, thus putting your auto increment back to 1.

Hope this helps.

Link to comment
Share on other sites

Thanks guys - what I've done so far: truncated both cats_idx and inventory - then uploaded 1775 products into inventory under their main categories, and updated cats_idx . . . Then I uploaded the first round of cross-reference info to cats_idx to add those 1775 products to other categories. In a few moments, I will do the next round of cross-references to add select numbers to other cats as well, then when all is done I'll run fixCatCount utility. So far, all seems to be successfull :blink:

The first cat, shot glasses, will be last to populate . . .

http://avftexas.com/bellissimo/index.php

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...