auto-increment

When to fix auto-increment gaps in MYSQL

The database I am working on right now has records being added and removed by the 10s of thousands and because of this there are gaps in the auto-incremented key hundreds of thousands big and auto-increment numbers well into the billions. These numbers are never stored to reference the individual record but are used to reference the re...

Using AUTO_INCREMENT in MYSQL

Why do I get the following exception when I did this, what mistake did i made? What is the right way to insert tuple into tables with AUTO_INCREMENT fields? How about delete, is it possible to update the ids? string connStr = "server=localhost;user=root;database=test;port=3306;password=XXX;"; MySqlConnection conn = new MySqlConnection(c...

Django/Python: How can I make the following number increment (not in database)

I would like to create a number like: 000000000001 to save to the database. I obviously cannot increment in this fashion (I don't think) in a database, so I'm looking for the most efficient method for pulling the previous number from the database and incrementing it by 1 to create the next record: 000000000002 and so on... If I st...

Custom PrimaryKey Generation with autoincrement

I need to define and generate primary key for 2 or more tables. Tables hold same type of data but FOR Some BUSINESS RULES we have to make them separate say like TableA = LOCAL_CUSTOMERS TableB = INTERNATIONAL_CUSTOMERS Both hold same columns like, CUSTOMER_ID C_NAME, CITY ....etc While designing the Primary Key I want these keys to b...

Hibernate Auto Increment ID

Hi.I have a j2ee application using hibernate with annotation. How do I annotate the Id field in my pojo class to set it as auto increment or auto generated. and in adding the bean do I leave that field in my bean null? ...

MySQL Cardinality vs Auto-Increment Counter

Is the MySQL cardinality number related to the auto-increment counter? ...

Resetting auto-increment column back to 0 daily

Is there a way in postgresql to have an auto-incrementing column reset back to zero at a specified time every day? ...

Mysql 5.1.42 alter table auto_increment = 0 doesn't work, truncate does

For my automated acceptance tests, I want inserts to start with id=1. I achieved this on one PC (XP 32bit, mysql 5.1.something) with (after deleting all rows from the table), "alter table tableName auto_increment = 0". I'm now setting up a new PC (Windows 7 64bit, mysql 5.1.42), and this command seems to have no effect. I can see in the...

"Auto increment" alphabet in java?

"Auto increment" alphabet in java - is this possible? From A to Z without a 3rd party library? ...

In a master-master setup, what command or files do I edit so that it can auto-increment by 2?

One server increment 1, 3, 5. The other server increment 2, 4, 6 ...

Is there any harm in resetting the auto-increment?

I have a 100 million rows, and it's getting too big. I see a lot of gaps. (since I delete, add, delete, add.) I want to fill these gaps with auto-increment. If I do reset it..is there any harM? If I do this, will it fill the gaps?: mysql> ALTER TABLE tbl AUTO_INCREMENT = 1; ...

MySQL row declarations?

What do these mean in MySQL? I'm using MySQL workbench and I see I can specify a new column as these... (I noted my guesses) PK – (primary key) NN – (non null) BIN – (binary?) UN – (Unicode?) ZF- (???) AI – (autoincrement?) Is AI exactly like an Identity specification in MSSQL? (Can I insert a record without specifying the value and ...

Using increment(attribute) to set value for user's rating

I'm thinking about writing an app with question and answer model. Answer has increment attribute that anyone can change to change the rating value. So if I click up on answer that someone else posted, the answer will show 1 point. But, how do I/can I, use that to increase the rating of the overall user. In essence it is very similar to ...

Using auto_increments to join MyISAM tables in MySQL

Hi everyone While I've been writing php for a long time, it was always a skill I learnt myself and I've just hit a minor crisis of confidence over table joins! Assuming a MySQL db auth containing MyISAM tables users and permissions: users - id (auto increment) - email permissions - id (auto increment) - name To join these tables in...

using Notepad++ how can i make a macro type situation in which a number increments?

for example i have about 500 lines. in the beginning of each line i want to add a number. so in line 1 i would want "1)" and then line 2 i would want "2)" i know i can do a macro in n++, but it wouldn't be incremental. is there any possible way to do this? ...

[Mysql]: Inserting values into an intermediate table

I have recently added an intermediary table to link two tables. Tables: Purchase: Transaction_Id Purchase_Id Schedule: Show_Id Price Purchase_Schedule: PurchaseId(fk) Show_Id(fk) My problem is that purhcase_id is on auto_increment. So i'm not sure where to pull that ID from. I was going to do something like this... INSERT...

SQL Server unique auto-increment column in the context of another column

Suppose the table with two columns: ParentEntityId int foreign key Number int ParentEntityId is a foreign key to another table. Number is a local identity, i.e. it is unique within single ParentEntityId. Uniqueness is easily achieved via unique key over these two columns. How to make Number be automatically incremented in the c...

MySQL - Auto Increment after delete

I have a MySQL table with a primary key field that has AUTO_INCREMENT on. After reading other posts on here I've noticed people with the same problem and with varied answers. Some recommend not using this feature, others state it can't be 'fixed'. I have: course table - with 2 fields - courseID, courseName Example: Number of records i...

Saving auto increment in MySQL

Hello, I am trying to sync between 2 tables: I have active table where has auto_increment, and I have archive table with the same values. I would like both ID's to be unique (between the tables as well) - I mean, I would like to save auto incremenet, and if I UNION both table I still have uniqness. How can I do that? Is there a possibili...

In Symfony with the Doctrine ORM how do you default autoincrement columns to integer and not bigint?

It seems that in Symfony 1.4 with Doctrine that when generating auto-increment columns (id) it defaults to bigint. This seems like total overkill and I would just like to default it to an integer instead. The following produces a primary key column named id that is a bigint JobeetCategory: actAs: { Timestampable: ~ } columns: ...