Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-20 Thread drum.lu...@gmail.com
Sorry guys... *WRONG *email On 17 March 2016 at 14:29, drum.lu...@gmail.com wrote: > >>> >> SELECT ​'test_'​ || substring(uuid_generate_v4()::text, 1, 1); >> >> Or use a sequence, or just compute "ROW_NUMBER() OVER ()" and tack that >> on. >> >> David J. >> ​ >> >> > Well.. I was able to do it b

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-18 Thread drum.lu...@gmail.com
> > >> > SELECT ​'test_'​ || substring(uuid_generate_v4()::text, 1, 1); > > Or use a sequence, or just compute "ROW_NUMBER() OVER ()" and tack that on. > > David J. > ​ > > Well.. I was able to do it by using: > INSERT INTO dm.billables_links (billable_id) VALUES ((SELECT billable_id > FROM junk.w

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-15 Thread David G. Johnston
On Tue, Mar 15, 2016 at 2:48 PM, drum.lu...@gmail.com wrote: > > >>> I wouldn't ask if I wouldn't have tested it! >>> >>> Will have a look. >>> >>> ​ >> I didn't asked if you tested what you did post. I asked if you tried >> anything else before asking to be fed the answer. If you did it w

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-15 Thread John R Pierce
On 3/15/2016 2:48 PM, drum.lu...@gmail.com wrote: It's already working: INSERT INTO junk.wm_260_billables2 (account_id, code, info) SELECT account_id, 'test_' || uuid_generate_v4(), info FROM junk.wm_260_billables1; BUT.. I'm getting a very long UUID - Would like some smaller

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-15 Thread drum.lu...@gmail.com
> >>> >> I wouldn't ask if I wouldn't have tested it! >> >> Will have a look. >> >> ​ > I didn't asked if you tested what you did post. I asked if you tried > anything else before asking to be fed the answer. If you did it would be > nice to include those other attempts. > > David J. > ​ > > It

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-15 Thread David G. Johnston
On Tue, Mar 15, 2016 at 2:35 PM, drum.lu...@gmail.com wrote: > > > On 16 March 2016 at 10:30, David G. Johnston > wrote: > >> On Tue, Mar 15, 2016 at 2:01 PM, drum.lu...@gmail.com < >> drum.lu...@gmail.com> wrote: >> >>> > Not reading the documentation for functions you've never heard o

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-15 Thread drum.lu...@gmail.com
On 16 March 2016 at 10:30, David G. Johnston wrote: > On Tue, Mar 15, 2016 at 2:01 PM, drum.lu...@gmail.com < > drum.lu...@gmail.com> wrote: > >> >>> Not reading the documentation for functions you've never heard of makes >>> the list. >>> >>> David J. >>> >> >> INSERT INTO junk.test1 (accou

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-15 Thread David G. Johnston
On Tue, Mar 15, 2016 at 2:01 PM, drum.lu...@gmail.com wrote: > >>> >> Not reading the documentation for functions you've never heard of makes >> the list. >> >> David J. >> > > INSERT INTO junk.test1 (account_id, code, info)SELECT account_id, > uuid_generate_v4(), infoFROM junk.test2; > > It wor

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-15 Thread drum.lu...@gmail.com
> > >> > Not reading the documentation for functions you've never heard of makes > the list. > > David J. > INSERT INTO junk.test1 (account_id, code, info)SELECT account_id, uuid_generate_v4(), infoFROM junk.test2; It works but I get data like: abc77f31-0ee6-44fd-b954-08a3a3aa7b28 f307fb42-23e5-

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-15 Thread Brent Wood
NIWA's IT systems. From: pgsql-general-ow...@postgresql.org on behalf of drum.lu...@gmail.com Sent: Tuesday, March 15, 2016 10:56 AM To: James Keener Cc: David G. Johnston; Postgres General Subject: Re: [GENERAL] Unique UUID value - PostgreSQL 9.2 On 15 Marc

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread David G. Johnston
On Monday, March 14, 2016, drum.lu...@gmail.com wrote: > > On 15 March 2016 at 12:05, David G. Johnston > wrote: > >> On Mon, Mar 14, 2016 at 4:05 PM, David G. Johnston < >> david.g.johns...@gmail.com >> > wrote: >> >>> On Mon, Mar 14, 2016 at 3:51 PM, drum.lu...@gmail.com >>> < >>> drum.lu...@

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread John R Pierce
On 3/14/2016 6:41 PM, drum.lu...@gmail.com wrote: So I'm doing: CREATE EXTENSION "uuid-ossp"; INSERT INTO junk.wm_260_billables2 (account_id, code, info) SELECT account_id, code || '_' || nextval('uuid_generate_v4()')::text, info FROM junk.wm_260_billables1; Getting the error:

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread drum.lu...@gmail.com
On 15 March 2016 at 12:05, David G. Johnston wrote: > On Mon, Mar 14, 2016 at 4:05 PM, David G. Johnston < > david.g.johns...@gmail.com> wrote: > >> On Mon, Mar 14, 2016 at 3:51 PM, drum.lu...@gmail.com < >> drum.lu...@gmail.com> wrote: >> >>> I just need to know how can I do all of this >>> >> >

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread David G. Johnston
On Mon, Mar 14, 2016 at 4:05 PM, David G. Johnston < david.g.johns...@gmail.com> wrote: > On Mon, Mar 14, 2016 at 3:51 PM, drum.lu...@gmail.com < > drum.lu...@gmail.com> wrote: > >> I just need to know how can I do all of this >> > > ​You may have missed my prior email. > > You cannot COPY directl

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread David G. Johnston
On Mon, Mar 14, 2016 at 3:51 PM, drum.lu...@gmail.com wrote: > I just need to know how can I do all of this > ​You may have missed my prior email. You cannot COPY directly into the target table. You must copy to a staging table. You then insert from the staging table to the target table, list

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread drum.lu...@gmail.com
On 15 March 2016 at 11:44, Brent Wood wrote: > Not best practice but perhaps viable... > > > In the target table add a serial datatype column as part of the unique > constraint. > > > Do not populate this column explicitly on insert, but have the db do it > for you. It will allocate an incrementa

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread drum.lu...@gmail.com
> > > > On the target table, I've got a CONSTRAINT: > >> ALTER TABLE dm.billables >> ADD CONSTRAINT uc_billable_code_unique_per_account UNIQUE("account_id", >> "code"); > > > So I'm importing a CSV file with repeated values on the field "code" > Example: > >> 'Interpreting Normal/AH' >> 'Interpre

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread drum.lu...@gmail.com
On 15 March 2016 at 10:46, James Keener wrote: > Is a uuid a valid value in the application making use of the data? Why > can't you add the column to table b and then import, or use create the uuid > in the import select clause? I'm also having trouble understanding the > problem and why you've d

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread James Keener
Is a uuid a valid value in the application making use of the data? Why can't you add the column to table b and then import, or use create the uuid in the import select clause? I'm also having trouble understanding the problem and why you've discounted the options you've not even told us you've c

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread David G. Johnston
On Mon, Mar 14, 2016 at 2:37 PM, drum.lu...@gmail.com wrote: > >> > I want to import data from table A to table B, but when doing it the > column "code" on table B has to have some unique random data. > > I could use UUID like: > insert into "TB" ("Id", "Title") values (uuid_generate_v4(), '111')

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread drum.lu...@gmail.com
On 15 March 2016 at 10:29, David G. Johnston wrote: > On Mon, Mar 14, 2016 at 2:13 PM, drum.lu...@gmail.com < > drum.lu...@gmail.com> wrote: > >> Hi all, >> >> > favorite >> >> >> I've got 2 tables: >> >

Re: [GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread David G. Johnston
On Mon, Mar 14, 2016 at 2:13 PM, drum.lu...@gmail.com wrote: > Hi all, > > favorite > > > I've got 2 tables: > > Temp-Table > Table-A > > Need to copy all the data from *Temp-Table* to *Table-A*. But the

[GENERAL] Unique UUID value - PostgreSQL 9.2

2016-03-14 Thread drum.lu...@gmail.com
Hi all, down votefavorite I've got 2 tables: Temp-Table Table-A Need to copy all the data from *Temp-Table* to *Table-A*. But there is a Constraint that does not allow me to have duplicated items. So