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
2 answers

EF4 Oracle Identity Insert

Does anyone know if its possible to call an oracle's sequence.NextVal from ef4 without using StoredProcedure? I have an Oracle db from a client which I cannot modify, so stroedproc are not an option for me. I use ef4 ctp5. Thank!
1
vote
1 answer

Copy Data from One SQL Server Table to Other in Same Database Without Specifying Columns

In SQL Server there is the ability to INSERT all of the data from one table into another using the following statement: INSERT INTO TABLE1 SELECT * FROM TABLE2 When running this on a table with an identity column, even though we have run the…
Doctor Blue
  • 3,769
  • 6
  • 40
  • 63
1
vote
0 answers

SSIS - Load data from Staging Area into Dimension having a Identity Column

I've the following table created: CREATE TABLE [dbo].[DIM_PRODUCT]( [product_id] [int] IDENTITY(1,1) NOT NULL, [product_name] [varchar](60) NOT NULL, CONSTRAINT [PK_DIM_PRODUCT] PRIMARY KEY CLUSTERED ( [product_id] ASC )WITH (PAD_INDEX…
Pedro Alves
  • 1,004
  • 1
  • 21
  • 47
1
vote
1 answer

Merging SQLite3 tables with identical primary keys

I am trying to merge two tables with financial information about the same list of stocks: the first is the prices table (containing, daily, weekly, monthly, etc... price data) and the second is the ratios table (containing valuation and other…
1
vote
1 answer

Any equivalent pseudo columns in Teradata like ROWNUM in Oracle

Is there any pseducolumn concept in Teradata like ROWNUM in Oracle or, is there any way to get first 100 rows of a table ? Thanks.
user7149478
1
vote
1 answer

Replacing PK's in Existing SQL DB Tables

Right now I have a DB where the PK's are int IDENTITY. I recently, in the last year, was tasked with adding these to a Replication Topology. This has worked out quite well with the exception of the IDENTITY fields. I want to explore my options for…
Refracted Paladin
  • 12,096
  • 33
  • 123
  • 233
1
vote
4 answers

How to add +1 in a sort column

I have a table column named sort which is using for sorting rows (1 2 3... etc). When I insert a new row, how can I automatically add an increment +1 in this column? For example, if the last row value is 20, the new should be 21. I tried to set this…
qadenza
  • 9,025
  • 18
  • 73
  • 126
1
vote
1 answer

Make R user-defined-function for data.table commands - How to refer a column properly

I have the df1 data df1 <- data.frame(id=c("A","A","A","A","B","B","B","B"), year=c(2014,2014,2015,2015), month=c(1,2), new.employee=c(4,6,2,6,23,2,5,34)) id year month…
1
vote
2 answers

NoNullAllowedException error when inserting data to a datagridview despite identity column is set to be auto-incremented

I have put a DataGridView in my program such that this DataGridView is corresponding to a dataset of one table and this table has a auto-incremented identity column(also,this column is set to be primary key). This identity column is not visible in…
samsam114
  • 987
  • 2
  • 8
  • 20
1
vote
2 answers

Is it possible to auto increment a property which is not the primary key in Entity Framework?

Is it possible to have a primary key and another field which is not the primary key with the "auto increment" function in Entity Framework? I found this on the web, tried it, but it does not work: public int Id { get; set;…
Jo Smo
  • 6,923
  • 9
  • 47
  • 67
1
vote
1 answer

SQLite + Entity Framework 4.0 + Identity column/Autoinc does not work

This is my table: -- Original table schema CREATE TABLE [SchoolYear] ( [Start] datetime NOT NULL, [End] datetime NOT NULL, [Id] integer PRIMARY KEY ON CONFLICT ABORT AUTOINCREMENT NOT NULL ); My Entity in the EF designer has…
msfanboy
  • 5,273
  • 13
  • 69
  • 120
1
vote
1 answer

Weird lines in python file, can't extract column

0 0: 1 0 1: 1 0 1: 0 1 0: 0 I have a file, that looks like something above. I am trying to extract this by columns into arrays by using numpy.loadtxt of python. Ideally, I want many arrays, or at least a data structure in which the arrays…
1
vote
4 answers

Split table and insert with identity link

I have 3 tables similar to the sctructure below CREATE TABLE [dbo].[EmpBasic]( [EmpID] [int] IDENTITY(1,1) NOT NULL Primary Key, [Name] [varchar](50), [Address] [varchar](50) ) CREATE TABLE…
The King
  • 4,600
  • 3
  • 39
  • 58
1
vote
3 answers

Not getting key value from Identity column back after inserting new row with SubSonic ActiveRecord

I'm sure I'm missing the obvious answer here, but could use a hand. I'm new to SubSonic and using version 3. I've got myself to the point of being able to query and insert, but I'm stuck with how I would get the value of the identity column back…
1
vote
2 answers

SQL: without a cursor, how to select records making a unique integer id (identity like) for dups?

If you have the select statement below where the PK is the primary key: select distinct dbo.DateAsInt( dateEntered) * 100 as PK, recordDescription as Data from MyTable and the output is something like this (the first numbers…
Zachary Scott
  • 20,968
  • 35
  • 123
  • 205