Here's an interesting problem!
When a sequence clashes with data already in that table:
CREATE TABLE clients (
id serial NOT NULL PRIMARY KEY UNIQUE,
name varchar(64));
-- import OLD clients, with their original ID#...
INSERT INTO clients VALUES (3, 'Dave');
INSERT INTO clients VALUES (4, 'Sally');
-- done! let the world add new clients now
INSERT INTO clients (name) VALUES ('Harry');
-- no problems, id=1
INSERT INTO clients (name) VALUES ('Mary');
-- no problems, id=2
INSERT INTO clients (name) VALUES ('Burt');
ERROR: duplicate key violates unique constraint "clients_pk ey"
I thought Postgres would be smart enough to make the clients_id_seq
skip existing numbers, but I guess not!
Do I, instead, have to be smart enough to set the sequence over the
highest existing id# from my imported data, so that it can blindly
increment without clashing?
If so, setval() would be best for that, right?
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster 1 1636
On Fri, Oct 08, 2004 at 03:00:07 -0700,
Miles Keaton <mi*********@gm ail.com> wrote: I thought Postgres would be smart enough to make the clients_id_seq skip existing numbers, but I guess not!
It wouldn't be very efficient to do that.
Do I, instead, have to be smart enough to set the sequence over the highest existing id# from my imported data, so that it can blindly increment without clashing?
That is normally what you want to do.
If so, setval() would be best for that, right?
Yes.
---------------------------(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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: R. Rajesh Jeba Anbiah |
last post by:
Just found this page <http://stock.ter.dk/session.php> Really interesting...
--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
|
by: Bruno R. Dias |
last post by:
Perhaps it would be interesting to program a virtual machine simulating
an ancient computer (such as the pdp-7). Then, it would be rather
interesting to code for it (porting gcc to it maybe?). I think it would
be fun to play with the long-forgotten art of coding in machine language.
And what about a fictional computer, such as one that works on an
entirely different way (such as a non-binary computer)?
It wouldn't be very useful, but...
|
by: Nick Coghlan |
last post by:
Thought some folks here might find this one interesting. No great revelations,
just a fairly sensible piece on writing readable code :)
The whole article:
http://www.acmqueue.com/modules.php?name=Content&pa=showpage&pid=271&page=1
The section specifically on white space:
http://www.acmqueue.com/modules.php?name=Content&pa=showpage&pid=271&page=3
Cheers,
|
by: Richard |
last post by:
Considering the code below.
Adapting this part of the code from meyerweb.com to my own use, I was
playing around with some values and came up with an interesting result I
like.
Copy and paste the code and try it out and you'll see what I mean.
The problem is, somehow in the coding, my thumbnails can not be presented as
they are given.
The dimensions of the thumbnails are totally dependent upon the fixed value
of the height in the first...
|
by: Yoav Dotan |
last post by:
Hi.
If anyone is interested to participate in a very
interesting project, and has an extensive knowhow in .NET
environment, pls. email (CV is a +) your contact email and
name to Yoav at ydotan@netvision.net.il
Have a lovely fun day.
Yoav
| |
by: Davy |
last post by:
I found a interesting pointer problem.
What does the pointer mean?
EXTERN short (*blocks);
And what does the malloc mean?
blocks =
(short (*))malloc(count*sizeof(short ));
Any suggestions will be appreciated!
|
by: Mythran |
last post by:
Here is some code the provides some really interesting results! First, read
over the two methods in class 'A' and compare. Just by looking at them,
both results appear to return the EXACT same information the same way. But
the appearances are deceiving! Copy and paste into a console application,
then set the configuration to Release mode :)
using System;
using System.Diagnostics;
using System.Reflection;
|
by: Mike |
last post by:
Hi
I am wonderinf if there are interesting examples to learn C.
Or any good idea?
Mike
|
by: timer |
last post by:
In the years past, there used to very interesting discussions in c.l.c
But now, topics are not as interesting anymore.
What happened?
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |