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
1
vote
5 answers

rearrange the identity column value in sql server

Please help me! I have a table will a identity field the value are, for example, 1, 2, 4, 6, 8, 10, 11 .... etc. I want to make it in a sequence, that is, 1,2,3,4,5,6,7... without using drop Thanks
user634036
  • 99
  • 5
  • 10
1
vote
0 answers

SQL Developer new column resets identity column setting

I am running SQL Developer Version 18.1.0.095 on a MacBook Pro. Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production I’ve encountered an issue regarding sequences and triggers which seems unusual and I’d like to know if it’s…
dob_stack
  • 21
  • 1
1
vote
4 answers

SQL Server 2008 R2 Insert Stored Procedure Syntax with Identity Field

Good Afternoon, I've written a very basic stored procedure that will be used to insert QuestionText and QuestionStatus into the Questions table with QuestionID int Primary Key set as having Identity. The syntax is as follows: CREATE PROCEDURE…
SidC
  • 3,175
  • 14
  • 70
  • 132
1
vote
1 answer

Redshift Copy command identity column is alternate value due to number of slices

I am trying to achieve sequential incremental values in the identity column of Redshift while running copy command. Redshift-Identity column SEED-STEP behavior with COPY command is an excellent article I followed to slowly move towards my target,…
Aakash Basu
  • 1,689
  • 7
  • 28
  • 57
1
vote
4 answers

List to Dictionary in pandas?

I have a column which has values stored as list. The column looks like: [{'key': 'firebase_screen_class', 'value': 'MainViewController'}, {'key': 'firebase_event_origin', 'value': 'auto'}, {'key': 'firebase_screen_id', 'value':…
nk23
  • 179
  • 1
  • 10
1
vote
1 answer

How to reset Firebird 3.0 identity column

I am using Firebird 3 for my project and I added identity columns for auto-increment columns. Before publishing it, I tested the database with thousands of records now I want to reset the column back to zero but I couldn't find any solution. Here is…
Core
  • 601
  • 2
  • 7
  • 19
1
vote
2 answers

How to modify column to auto increment in PL SQL Developer?

I have created one table in PL SQL Developer. CREATE TABLE Patient_List ( Patient_ID number NOT NULL, Patient_Name varchar(50) NOT NULL, Patient_Address varchar(100) NULL, App_Date date NULL, Descr varchar(50), CONSTRAINT…
Shreyas Pednekar
  • 1,285
  • 5
  • 31
  • 53
1
vote
1 answer

JPA Annotations - How to retrieve all entities with a specific column value

Let say I have an entity object Customer with an "OneToMany" relation to Order. I want that when ever a "Customer" get loaded, only his orders with the Id = 1234, 5678 get loaded to. Any ideas? @Entity @Table(name = "Customer") public class Customer…
Lycone
  • 650
  • 9
  • 18
1
vote
1 answer

Python-MSSQL (pymssql) Set a field Identity Column

I have been trying to set the ObjectID as Identity column using python on SQL. The below SQL statment works on Management Studio (SSMS) and sets the ObjectID as Identity column. The code works, but when checking the table on SSMS, I don't see…
EFKan
  • 634
  • 5
  • 9
1
vote
1 answer

Workaround for Teradata identity columns and volatile/temp tables issue

I'm somewhat new to Teradata and cannot understand why I can't select an identity column within a volatile table. When executing something like the following, I get the error below. create multiset volatile table Temp_Events as ( select…
eTothEipiPlus1
  • 577
  • 2
  • 9
  • 28
1
vote
4 answers

In R how to remove all columns of a matrix that contain a negative number?

I want to remove those columns from a matrix M that contain at least one negative number. For example, if M = (1 0 0 1) (1 -1 0 2) (2 3 4 -3) I want M to become M = (1 0) (1 0) (2 4) How to type M <-…
mercury0114
  • 1,341
  • 2
  • 15
  • 29
1
vote
1 answer

How should I handle maintaining row Identity for new records in Linq / Entity Framework?

What is the proper way to create a new unique shared key when using Linq and EF with SQL? I could use a GUID upon inserting the record but I only want want my keys to have 7 digits or characters in it as they will appear in the URL of my MVC…
1
vote
1 answer

Add an identity column to existing table which is changing always

I have an existing table with 15 million rows in it. I want to add an identity column and make it primary key. The problem is this table is always moving (inserts, updates, deletes). Is it possible to add the identity column with this? Or I have to…
Vikram
  • 608
  • 1
  • 7
  • 18
1
vote
2 answers

How to add Identity Column in SQL server?

Here is my table and Id is unique constraint...Now I want to add Identity Column in ID .Can anyone help me how to do it with TSQL. This is existing table.
Awesome
  • 560
  • 2
  • 7
  • 18
1
vote
3 answers

SQL Server 2008: what happened if identity oversteps a maximal value of int?

Imagine we have a table: create table MYTABLE ( id int IDENTITY(1,1) ,name varchar(10) ) We have to insert a lot of rows into the table. Does anybody know what will happen when a generated identity value oversteps a maximal integer value…
Timofey
  • 2,478
  • 3
  • 37
  • 53