All Questions

277
votes
16answers
633223 views

How to create id with AUTO_INCREMENT on Oracle?

It appears that there is no concept of AUTO_INCREMENT in Oracle, up until and including version 11g. How can I create a column that behaves like auto increment in Oracle 11g?
874
votes
18answers
886265 views

How to reset AUTO_INCREMENT in MySQL?

How can I reset the auto_increment of a field? I want it to start counting from 1 again.
47
votes
6answers
119907 views

SQL Server, How to set auto increment after creating a table without data loss?

I have a table table1 in SQL server 2008 and it has records in it. I want the primary key table1_Sno column to be an auto-incrementing column. Can this be done without any data transfer or cloning ...
24
votes
4answers
36573 views

Auto increment table column

Using Postgres, I'm trying to use AUTO_INCREMENT to number my primary key automatically in SQL. However, it gives me an error. CREATE TABLE Staff ( ID INTEGER NOT NULL AUTO_INCREMENT, Na...
51
votes
3answers
259954 views

How to make MySQL table primary key auto increment with some prefix

I have table like this table id Varchar(45) NOT NULL AUTO_INCREMENT PRIMARY KEY, name CHAR(30) NOT NULL, I want to increment my id field like 'LHPL001','LHPL002','LHPL003'... etc. What should I hav...
52
votes
16answers
105922 views

Auto Increment after delete in MySQL

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 ...
184
votes
6answers
186413 views

Get current AUTO_INCREMENT value for any table

How do I get the current AUTO_INCREMENT value for a table in MySQL?
188
votes
6answers
370646 views

How to set initial value and auto increment in MySQL?

How do I set the initial value for an "id" column in a MySQL table that start from 1001? I want to do an insert "INSERT INTO users (name, email) VALUES ('{$name}', '{$email}')"; Without specifying t...
430
votes
7answers
442993 views

PostgreSQL Autoincrement

I'm switching from MySQL to PostgreSQL and was wondering how I can do autoincrement values. I saw in the PostgreSQL docs a datatype "serial", but I get syntax errors when using it (in v8.0).
197
votes
10answers
232499 views

Reset AutoIncrement in SQL Server after Delete

I've deleted some records from a table in a SQL Server database. Now the ID's go from 101 to 1200. I want to delete the records again, but I want the ID's to go back to 102. Is there a way to do this ...

Previous Next