views:

113

answers:

1

To get the seed and step values of an identity column in sql server i can use this syntax

SELECT ColumnName = name, Seed = seed_value, Step = increment_value 
  FROM sys.identity_columns

So far in MySql i have found that if i use this syntax

SELECT * FROM INFORMATION_SCHEMA.TABLES
 WHERE auto_increment IS NOT NULL

I can at least find out which columns are an identity...

The question being how can i get the SEED and STEP values of the identity column from the MySQL Schema.

+2  A: 

You can get the system wide settings using:

SHOW VARIABLES LIKE 'auto_inc%';

The result:

| Variable_name            | Value 
+--------------------------+-------
| auto_increment_increment | 1     
| auto_increment_offset    | 1  

Reference:

The only AUTO_INCREMENT attribute you can control outside of this is the starting value, using an ALTER TABLE statement:

ALTER TABLE tbl AUTO_INCREMENT = 100;
OMG Ponies
So from what im gathering the auto_increment column on information_Schema.tables is actually the seed value and the "step" or "offset" can only be ++ or 1 unless changed to a special type of increment.
Matthew McDonald
@mmcdonald: The defaults are for increment and offset are 1 - you can change them but it's instance wide, not per table or database.
OMG Ponies