# PostgreSQL DBMS Server Question (newbie stuff)

**URL:** https://boards.straightdope.com/t/postgresql-dbms-server-question-newbie-stuff/40590
**Category:** Factual Questions
**Created:** [November 10, 2000, 2:34am UTC](https://boards.straightdope.com/t/postgresql-dbms-server-question-newbie-stuff/40590 "2000-11-10T02:34:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Joe\_Cool](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@Joe\_Cool](https://boards.straightdope.com/u/Joe_Cool)
#### Post date: [November 10, 2000, 2:34am UTC](https://boards.straightdope.com/t/postgresql-dbms-server-question-newbie-stuff/40590/1 "2000-11-10T02:34:11Z")

</div>

Ok, I hate not knowing basic stuff, but you gotta start someplace, right?

The question is this: I’m creating a table with a number of fields, one of which is an integer Primary Key. Is there a way to make the server automatically assign a unique number every time a record is added? I don’t want to have to write a subroutine into my front-end that figures out what the highest Key value is then increment.

So…Any help available? I’ve searched the man pages, the packaged help, usenet, etc and no luck.

Thanks in advance.

---

<div class="post-metadata">

### Author: ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)
#### Post date: [November 10, 2000, 2:40am UTC](https://boards.straightdope.com/t/postgresql-dbms-server-question-newbie-stuff/40590/2 "2000-11-10T02:40:18Z")

</div>

When you create the table, make sure you set the auto-increment property for that field.

CREATE TABLE Foo (primkey int auto\_increment, otherfield int, yet\_another\_field blob);

oughta do it.

---

<div class="post-metadata">

### Author: ![Joe\_Cool](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@Joe\_Cool](https://boards.straightdope.com/u/Joe_Cool)
#### Post date: [November 12, 2000, 11:37pm UTC](https://boards.straightdope.com/t/postgresql-dbms-server-question-newbie-stuff/40590/3 "2000-11-12T23:37:20Z")

</div>

Thanks for the input friedo. It didn’t work, but searching on your answer I found what I was looking for.

Now if I could only figure out how to insert a null date into a date field without returning an error…_!#&!@^!@_@#
