473,388 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

serial data type

Can I use the serial data type in lieu of an 'auto_number' field?

I asked something like this some months ago and it seems that
auto_number fields were addressed through a combination of triggers and
procedures to ensure that there were do duplicate KEYS generated.

Is it realistic to use the serial data type as a KEY?

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #1
6 1840
Tom Allison <ta******@tacocat.net> writes:
Can I use the serial data type in lieu of an 'auto_number' field?
What are the exact semantics of an "auto_number" field?
I asked something like this some months ago and it seems that
auto_number fields were addressed through a combination of triggers
and procedures to ensure that there were do duplicate KEYS generated.

Is it realistic to use the serial data type as a KEY?


Lots and lots of people do. If you're just looking for a unique key
column for a single table, it works fine.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #2


Doug McNaught wrote:
Is it realistic to use the serial data type as a KEY?

Lots and lots of people do. If you're just looking for a unique key
column for a single table, it works fine.

-Doug


This is essentially what I'm looking for.

Any idea how to set up a timestamp=now on every insert/update ?

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #3
Tom Allison <ta******@tacocat.net> writes:
Doug McNaught wrote:
Is it realistic to use the serial data type as a KEY?

Lots and lots of people do. If you're just looking for a unique key
column for a single table, it works fine.
-Doug


This is essentially what I'm looking for.

Any idea how to set up a timestamp=now on every insert/update ?


Use a trigger.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #4
On Sat, Sep 25, 2004 at 07:20:23PM -0400, Tom Allison wrote:

Any idea how to set up a timestamp=now on every insert/update ?


when you create your table, use:

create table mytable (
id serial primary key,
updated timestamp default(now()),
mydata int4
);

Joe
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #5
Joseph Healy <jo*******@dodo.com.au> writes:
On Sat, Sep 25, 2004 at 07:20:23PM -0400, Tom Allison wrote:

Any idea how to set up a timestamp=now on every insert/update ?


when you create your table, use:

create table mytable (
id serial primary key,
updated timestamp default(now()),
mydata int4
);


That won't change the timestamp on UPDATE queries; you need a trigger
for that.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #6


Doug McNaught wrote:
Joseph Healy <jo*******@dodo.com.au> writes:

On Sat, Sep 25, 2004 at 07:20:23PM -0400, Tom Allison wrote:
Any idea how to set up a timestamp=now on every insert/update ?


when you create your table, use:

create table mytable (
id serial primary key,
updated timestamp default(now()),
mydata int4
);

That won't change the timestamp on UPDATE queries; you need a trigger
for that.


Thanks!
Understood.

I'll get to that tomorrow. Right now I'm working on data types and
tables....

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Gavin | last post by:
Hi, I'm a newbie to programming of any kind. I have posted this to other groups in a hope to get a response from anyone. Can any one tell me how to make my VB program read the Bios serial number...
10
by: Conrad | last post by:
Greetings, I have a need to print from Win98SE to a little serial label printer provided by United Parcel, so based on Mark Hammond's recommendation in 'Programming on Win32' I decided to try...
0
by: Polerio Babao Jr.II | last post by:
file fbus3.py resource shared by Chris Liechti <cliechti@gmx.net> during the conversation last september 2002. I made it available so that other user would benefit from it. I've used with...
15
by: tom | last post by:
Hi, How do I get the serial number of the harddisk in .NET? I want this to be the same number even if the user has reformatted, so I do not want the volume serial number. Thanx, t
21
by: nephish | last post by:
i have an interesting project at work going on. here is the challenge. i am using the serial module to read data from a serial input. it comes in as a hex. i need to make it a binary and compare it...
2
by: Techie | last post by:
If I want to create a table with a triggter to retrive data fast in DB2 database, how can I do that? I know in informix we have serial as a data type. what is the equivalent in DB2? what is the...
6
by: Peter Krikelis | last post by:
Hi All, I am having a problem setting up input mode for serial communications. (Sorry about the long code post). The following code is what I use to set up my comm port.
12
by: Prabu Subroto | last post by:
Dear my friends... I am using postgres 7.4 and SuSE 9.1. I want to use auto_increment as on MySQL. I look up the documentation on www.postgres.com and I found "serial" . But I don't know...
5
by: Franklin M. Gauer III | last post by:
Hi All, I've written an ASP.NET application (webservice) that does simple serial communications via the .NET 2.0 SerialComm object. The application runs fine on my development machine. The...
4
by: max_mont | last post by:
Hi all, I'm a newbie in .NET technology. I've already developed Serial communication applications in C++ (WIN32). And I wanted to migrate to .NET technology. There is a serial component in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.