Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:05:23+00:00 2026-06-15T14:05:23+00:00

I am trying to run a query to check if a column auto increments.

  • 0

I am trying to run a query to check if a column auto increments. I can check type, default value, if it’s nullable or not, etc. but I can’t figure out how to test if it auto increments. Here is how I am testing for those other things:

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'my_table'
AND COLUMN_NAME = 'my_column'
AND DATA_TYPE = 'int'
AND COLUMN_DEFAULT IS NULL
AND IS_NULLABLE = 'NO'
--AND AUTO_INCREMENTS = 'YES'

Unfortunately there is no AUTO_INCREMENTS column to compare against. So how can I test if a column auto increments?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:05:24+00:00Added an answer on June 15, 2026 at 2:05 pm

    For MySql, Check in the EXTRA column:

    SELECT *
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'my_table'
        AND COLUMN_NAME = 'my_column'
        AND DATA_TYPE = 'int'
        AND COLUMN_DEFAULT IS NULL
        AND IS_NULLABLE = 'NO'
        AND EXTRA like '%auto_increment%'
    

    For Sql Server, use sys.columns and the is_identity column:

    SELECT 
        is_identity
    FROM sys.columns
    WHERE 
        object_id = object_id('my_table')
        AND name = 'my_column'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am trying to run this query in SQL but it is not
I'm trying to run the following query, but am not sure how to limit
I'm trying to run a query on a very simple table but I'm not
Hi i am trying to run a query on a database, but i keep
Hey guys I am getting this exception when trying to run the query Column
I'm trying to run a query to select customer audience, but it should select
I'm trying to run following query but it throws an error. DELETE b FROM
I'm trying to run a query on DBPedia.org via SPARQL. Basically, here's what I
I'm trying to run a simple query with PDO in PHP. The code is
I am trying to run the following query: SELECT COUNT(*) FROM ( SELECT *

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.