Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of MSSQL IDENTITY Column in MySQL

What is the equivalent of MSSQL IDENTITY Columns in MySQL? How would I create this table in MySQL?

CREATE TABLE Lookups.Gender (     GenderID   INT         IDENTITY(1,1) NOT NULL,     GenderName VARCHAR(32) NOT NULL ); 
like image 352
Allan Chua Avatar asked Apr 23 '12 15:04

Allan Chua


People also ask

What is identity column in MySQL?

An identity column is a column (also known as a field) in a database table that is made up of values generated by the database. This is much like an AutoNumber field in Microsoft Access or a sequence in Oracle.

What is Nvarchar in MySQL?

NVARCHAR stands for National Varchar in MySQL. Let us first create a table with one of the columns “StudentName” as NVARCHAR − mysql> create table DemoTable ( StudentName NVARCHAR(40), StudentCountryName VARCHAR(50) ); Query OK, 0 rows affected, 1 warning (0.49 sec)

What is Auto_increment in MySQL?

Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted.

What is @@ identity in SQL Server?

Remarks. After an INSERT, SELECT INTO, or bulk copy statement is completed, @@IDENTITY contains the last identity value that is generated by the statement. If the statement did not affect any tables with identity columns, @@IDENTITY returns NULL.


1 Answers

CREATE TABLE Lookups.Gender (     GenderID   INT         NOT NULL AUTO_INCREMENT,     GenderName VARCHAR(32) NOT NULL ); 
like image 53
Joe Stefanelli Avatar answered Sep 24 '22 11:09

Joe Stefanelli