K
K
Konstantin2018-10-16 00:53:34
MySQL
Konstantin, 2018-10-16 00:53:34

Using SEQUENCE in MySQL?

Does MySQL allow SEQUENCE?
I need something like this:

CREATE SEQUENCE [dbo].[SEQ_General]
    AS INT
    INCREMENT BY 1
    MINVALUE 1;

To later use this when creating a record:
CREATE TABLE <Table> (
 [Id]   BIGINT  NOT NULL DEFAULT (NEXT VALUE FOR dbo.SEQ_General)....

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Snewer, 2018-10-16
@Snewer

Use auto_increment

CREATE TABLE tablename (
     id MEDIUMINT NOT NULL AUTO_INCREMENT
);

S
Sanovskiy, 2018-10-16
@Sanovskiy

CREATE TABLE mysequenceTable (
  id INT NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
)

Then just insert a new record into the table and get a unique global ID
Kostylevko looks, but it will work.
Here's another option . But it's more difficult.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question