Questions tagged [identity-column]

An Identity column is a column in a database table that is made up of values managed by the server and cannot be modified, to be used as a primary key for the table. It is usually an auto-incrementing number.

Several Database products provide means to guarantee unique sequences of numeric values. Manually coding values for a primary key can cause problems.

Common database support: - Oracle: SEQUENCE (stand-alone number generator) and IDENTITY column clause that uses a system-generated SEQUENCE - mySQL: AUTO_INCREMENT column clause - Microsoft SQL Server, IBM DB2: SEQUENCE (stand-alone number generator)

See also for questions not related specifically to a primary key.

368 questions
2
votes
2 answers

SQL multiple tables with synced IDENTITY columns

I am working on "cleaning up" a database and need to synchronize the IDENTITY columns. I am using stored procedures to handle the data and mirror it from one table to the next (after cleaning it and correcting the datatypes). At some point in the…
jon3laze
  • 3,188
  • 6
  • 36
  • 69
2
votes
1 answer

order a row by column name of other data frame and match in length

For example you have this data frame : dd <- data.frame(b = c("cpg1", "cpg2", "cpg3", "cpg4"), x = c("A", "D", "A", "C"), y = c(8, 3, 9, 9), z = c(1, 1, 1, 2)) dd b x y z 1 cpg1 A 8 1 2 cpg2 D 3 1 3 cpg3 A 9…
XXXX992
  • 35
  • 1
  • 6
2
votes
1 answer

Help determining proper Identity Range sizes

I have a Merge Replication with ~200 subscribers. I am trying to determine what would be appropriate Identity Range Sizes on some of the tables. You see I inherited a DB structure that was not designed for Replication therefore all table PK's are…
2
votes
3 answers

Best way to move data between tables and generate mapping of old to new identity values

I need to merge data from 2 tables into a third (all having the same schema) and generate a mapping of old identity values to new ones. The obvious approach is to loop through the source tables using a cursor, inserting the old and new identity…
Daniel
  • 47,404
  • 11
  • 101
  • 179
2
votes
1 answer

SQL table function or means to tell if identity column has been used?

I was curious if there is a way to tell if an IDENTITY column has ever been incremented if there is no data within the table. (i.e. data item was inserted, then deleted)
mattgcon
  • 4,768
  • 19
  • 69
  • 117
2
votes
5 answers

SQL Server - Auto-incrementation that allows UPDATE statements

When adding an item in my database, I need it to auto-determine the value for the field DisplayOrder. Identity (auto-increment) would be an ideal solution, but I need to be able to programmatically change (UPDATE) the values of the DisplayOrder…
user356178
2
votes
1 answer

In SQL Server 2008, how should I copy data from database to another database?

I'm trying to write a stored procedure to copy a subset of data from one set of tables to an identical set of tables in a different database. The "source" database needs to be a parameter to the stored procedure. I've struggled with this for two…
2
votes
2 answers

Mysql statement to list tables of certain columns?

I'm trying to figure out the foreign keys relationship within my MySQL databases. I have many tables that has the "mydomain_id" column located in other tables. Is there a command line I can use to list all tables that has that particular column?
tester2001
  • 1,053
  • 3
  • 14
  • 24
2
votes
2 answers

MySQL Table Column has English values or Arabic

I have one table in MySQL which stores clients information. There are two description info columns like CLIENT_DETAIL_INFO and CLIENT_DETAIL_INFO_A There are more than 5 thousand records under clients table. What I want is, to identify Arabic column…
Aditya P Bhatt
  • 21,431
  • 18
  • 85
  • 104
2
votes
2 answers

How to detect binary & categorical columns coded as discrete numeric in r

I have a dataset that contains binary, categorical columns but coded as discreet numeric and continous features. I am trying to build a function that finds out the column indexes that does not contain numeric values. An example dataset is given…
syebill
  • 543
  • 6
  • 23
2
votes
2 answers

Assigning unique variable from a data.frame

This is a similiar question to this but my output results are different. Take the data: example <- data.frame(var1 = c(2,3,3,2,4,5), var2 = c(2,3,5,4,2,5), var3 = c(3,3,4,3,4,5)) Now I want to create…
lukeg
  • 1,327
  • 3
  • 10
  • 27
2
votes
2 answers

SQL IDENTITY column based on another column

Is there a way to define an identity column on another column? What I want to accomplish is a table that holds positions of an order and these orders can be put there anytime. So it could be that there are already lets say three positions in the…
Romano Zumbé
  • 7,893
  • 4
  • 33
  • 55
2
votes
3 answers

SQL IDENTITY COLUMN

I have an sql table which is basically a statement. Now lets say the records I have in my table have a date and an identity column which is autonumbered and defines the order which the transactions are displayed in the front end to the client. The…
andreas
  • 29
  • 1
  • 3
2
votes
1 answer

Return to 1 from autoincrement database field

Using SQL Server, I've got a column "ID" in my table that auto-increments every time I insert a new record. How can I reset this counter and return to 1?
img.simone
  • 632
  • 6
  • 10
  • 23
2
votes
1 answer

Identity Column Seems to Skip Values

I created a table in sqlserver 2012 with a primary key ID with identity turned on, and I found that the values it was inserting went from 1 to 55, then jumped to 1056. To be clear, the IDs it returned were as…
user3785958
  • 71
  • 1
  • 1
  • 4