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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:03:07+00:00 2026-05-31T23:03:07+00:00

I defined an attribute in my table of type serial4 , so when I

  • 0

I defined an attribute in my table of type serial4, so when I insert a new row, the attribute is automatically incremented:

myTable (id serial4, name varchar(25), whatever whatever, ...);

To insert a new entry, I just strip off the id attribute in the association list:

insert into myTable (name, whatever, ...) values ('foo', ...);

Now, if my table has a large number of attributes, the association list is exhausting to write.
I just want to write:

insert into myTable values (...);

But if the first attribute of myTable is the serial4 id. What should I write in the VALUES list to get the id being incremented +1 from the last inserted value?

insert into myTable values (?, 'foo', ...);
  • 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-31T23:03:08+00:00Added an answer on May 31, 2026 at 11:03 pm

    The INSERT command accepts the key word DEFAULT:

    INSERT INTO my_table VALUES (DEFAULT, 'foo', ...);
    

    The serial pseudo data type (synonym: serial4) is just a notational convenience for an integer column that retrieves its default values from an attached SEQUENCE. By using the DEFAULT key word, the next value from the sequence is inserted like any other default value.

    Details in the manual.

    Aside: it’s typically not advisable to omit the target column list in persisted code. Any later change to the table will break that code it confusing ways.

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

Sidebar

Related Questions

I have defined attribute is_first for table items. In model Item, i want to
I want to update an attribute defined by a variable in an activerecord model.
I have defined a tag with a CSS attribute overflow set to scroll. This
How can I set attribute to MVC2 user control defined in single file with
Possible Duplicate: How to access this attribute using jquery, given a div defined by
I want to create a new element with html5 data attributes defined, however they
My database table has a column defined to use ON UPDATE CURRENT_TIMESTAMP : Field:
Consider I have a user-defined type as follows: CREATE TYPE mytype AS (myvar character(1),
In my index.html page, I have an empty table defined as following: <body> ...
I defined a record named log . I want to create an mnesia table

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.