SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast omerie63's Avatar
    Join Date
    Jul 2004
    Location
    WISCONSIN
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Postgres: SERIAL, what's the insertion method?

    I am trying to insert into tables that have a serial type as pk. I make insert statements putting default where I need the pk(id). It works fine when I do it from the terminal but when I build a query string it does not work. It tells me that I am trying to insert a duplicate key.

    I Vacuumed the database and it still does it.

    I am doing something like this:

    CREATE TABLE myTable(
    id serial PRIMARY KEY,
    garb varchar(250),
    garb2 varchar(250)

    )

    INSERT INTO myTable VALUES(default, 'test', 'test');

    Please let me know,

    Erion

  2. #2
    SitePoint Enthusiast omerie63's Avatar
    Join Date
    Jul 2004
    Location
    WISCONSIN
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I seem so retoric but I guess I could do it like:

    INSERT INTO myTable (garb, garb2) VALUES('test', 'test');

    I guess you other people that did not know this before are learning with me here...

    I was just reminded of that from another forum,

    Great,

    I think I do not need to post questions becuase after a little time I seem to find out somehow.

    Patience man, I am telling you

    Take Care

  3. #3
    Non-Member
    Join Date
    Aug 2002
    Location
    USA
    Posts
    544
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, don't bother inserting default or serial (not the same thing) values.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •