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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:44:42+00:00 2026-06-17T23:44:42+00:00

I have a table t_user : CREATE TABLE t_user ( c_id bigint NOT NULL,

  • 0

I have a table t_user:

CREATE TABLE t_user
(
  c_id bigint NOT NULL,
  c_lastname character varying(255)
)

The table is not using any sequences to generate the IDs, instead these are calculated outside of Postgres (don’t ask, and don’t care about possible problems that this can cause).
Now there are some “holes” in a range from 0 to 1000 that I need to know of and fill up.

Is it possible to formulate a Postgres query that gives me all unused IDs in that table in a range from 0 to 1000?

  • 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-17T23:44:43+00:00Added an answer on June 17, 2026 at 11:44 pm

    It’s a classic case of using generate_series and an outer join:

    SELECT i FROM t_user RIGHT JOIN generate_series(0,1000) as i ON (c_id=i)
     WHERE c_id is null;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table defined as follows: CREATE TABLE [dbo].[T]( [FileID] [bigint] NOT NULL,
Let's say we have the following table: CREATE TABLE T ( ID INT, String1
I have a history table like below CREATE TABLE [dbo].[t_PettyCash_History] ( [TableName] [varchar] (500)
Assuming I have a table like this one: CREATE TABLE user_delegates ( [id] INT
I installed MySql on my own machine. I created database, create table, ... using
I have a need to create a user table type. My preference is to
We have a table T which contains a several char(8) columns (implicitly) which under
I have a table T with fields id, parentid , name. i make relationship
i have a table t_points in mySql like example in below. Name Surname Point
I have the following table @t: ParentId SkuName ChildId P1 X1 C1 C1 X2

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.