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 6979871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:56:28+00:00 2026-05-27T17:56:28+00:00

I have a SQLite database which stores UUIDs as the keys. UUIDs are very

  • 0

I have a SQLite database which stores UUIDs as the keys. UUIDs are very long and so for usability I have implemented a function which autocompletes a UUID prefix to the full UUID value (or returns NULL on non-unique prefix).

I was wondering if there is a query which can return the set of UUID prefixes such that each prefix is unique. This includes two cases: the one where each UUID prefix is the smallest size it can possibly be and the case that all UUID prefixes are the length of the longest UUID prefix needed for uniqueness.

For example if the data is:

AB1234DE...
AA1264DE...
BA2234DE...

The set of minimal prefixes would be:

AB
AA
B

The set of prefixes with the length necessary for uniqueness:

AB
AA
BA

Any idea how to accomplish this in a SQLite query? (the column is named id)

  • 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-05-27T17:56:29+00:00Added an answer on May 27, 2026 at 5:56 pm

    This could be implemented using analytic functions that for example Oracle DBMS has, but in sqlite there is no way to write such complex logic in sql query.

    The possible shorthand I could propose to use is:

    SELECT COUNT(*) as cnt
    FROM tbl
    GROUP BY SUBSTR(id, 0, 1)
    HAVING COUNT(*) > 1
    

    And increase the length of string in your programming language until this query returns no rows (or you can even make nested query) like:

    SELECT IF(COUNT(*) > 0, 'Duplicates found', 'No duplicates') AS result FROM (
        SELECT 1
        FROM tbl
        GROUP BY SUBSTR(id, 0, 1)
        HAVING COUNT(*) > 1
    )
    

    and increase substring length until result is not desired

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

Sidebar

Related Questions

I have an SQLite database within my Android application, which stores dates as integers.
I have an app which stores data in a SQLite database, when the app
I have a DataTable which I want to save to a SQLite Database Table.
I have an sqlite database which currently holds an integer field called Year which
I am creating application which stores the users financial information in a sqlite database.
I have a log file stored in an SQLite database which I would like
I have a DataMapper based SQLite database. I store the time at which the
I am making a small iPhone application in which I have implemented the database
I have one sqlite database which has one table in which I store the
I have one table in sqlite database which contains five different columns as shown

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.