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

  • SEARCH
  • Home
  • 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 7916889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:58:19+00:00 2026-06-03T14:58:19+00:00

In SQLite I can run the following query to get a list of columns

  • 0

In SQLite I can run the following query to get a list of columns in a table:

PRAGMA table_info(myTable)

This gives me the columns but no information about what the primary keys may be. Additionally, I can run the following two queries for finding indexes and foreign keys:

PRAGMA index_list(myTable)
PRAGMA foreign_key_list(myTable)

But I cannot seem to figure out how to view the primary keys. Does anyone know how I can go about doing this?

Note: I also know that I can do:

select * from sqlite_master where type = 'table' and name ='myTable';

And it will give the the create table statement which shows the primary keys. But I am looking for a way to do this without parsing the create statement.

  • 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-03T14:58:21+00:00Added an answer on June 3, 2026 at 2:58 pm

    The table_info DOES give you a column named pk (last one) indicating if it is a primary key (if so the index of it in the key) or not (zero).

    To clarify, from the documentation:

    The “pk” column in the result set is zero for columns that are not
    part of the primary key, and is the index of the column in the primary
    key for columns that are part of the primary key.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run the following query in SQLite 3: SELECT *, DISTANCE(latitude, longitude,
I have everything installed. But when I run rake db:create, I get the following:
Can SQLite sort naturally? For example, CREATE TABLE animals ( id INTEGER NOT NULL
Im just learning SQLite and I can't get my parameters to compile into the
I can't get SQLite Driver working in my sessionfactory. I downloaded SQLite 1.0.48 from
Running ubuntu 9.04 jaunty. When I run make I get the following error: Python
I need to run C++ code via eclipse which has SQlite. I can run
When I run this code in iPhone simulator ,I can not delete record from
I'm trying to get the hibernate-sqlite project to work. I downloaded it and can
I have the following SQL query that I am trying to run inside Microsoft

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.