Solved

Setting a column's datatype to autonumber

Posted on 2000-05-17
2
498 Views
Last Modified: 2006-11-17
I have noticed that in Access RDBMS you are able to set the data-type of a column to autonumber which then automatically assigns a unique identifying number to each row. Is there an equivalent SQL command for a database such as mySQL?
0
Comment
Question by:ubya308
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
rickbus101 earned 100 total points
ID: 2816682
Yes, it's the identity property with seed and increment values.

Here's the sql:

create table tablename
 (fieldname int identity (1, 10))

1 is the seed value and 10 is the increment value.

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2816703
If you want other UniqueIdentifier as datatype (that 128 byte long GUID), you may assign the Default value of the column to NEWID()

create table tablename
 (fieldname uniqueidentifier DEFAULT NEWID())
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question