Re: [SQL] surrogate key or not?

2004-07-21 Thread Josh Berkus
Markus, Iain, (B (B> Thus I see it more as an issue of business logic than performance. There are (B> of course many other considerations with relational theory and stuff like (B> that which you could debate endlessly. I expect that googling on "surrogate (B> keys" would yeild interesting resu

Re: [SQL] locks and triggers. give me an advice please

2004-07-21 Thread sad
thnx. i try to sound the idea to ensure myself that you are right. > begin transaction; > lock t1 in access exclusive mode; > > Turn off triggers and do your updates. > (Note, "truncate t1" is faster than "delete from t1" followed by a > "vacuum full" and you might consider running "reindex table

Re: [SQL] Inherited tables and new fields

2004-07-21 Thread Oliver Elphick
On Tue, 2004-07-20 at 15:36, Jeff Boes wrote: ... > Of course, had we used table inheritance, we'd do something like ... > >select * from draft_template ... > > but it wouldn't do exactly what we are doing now: that is, > fn_all_drafts() returns not only the contents of every row in the table

Re: [SQL] surrogate key or not?

2004-07-21 Thread Josh Berkus
Markus, Oh, so you want USEFUL answers. OK. > Now when I want to search for a type in types or another table that > references types(type_id), under what circumstances is it advisable to > have a surrogate integer key and not use the unique type name? When using the actual name will be a perfor

[SQL] Please help me.. problem in to_char

2004-07-21 Thread azah azah
Hi, I want convert from mysql to postresql, previously in mysql the code as below: SELECT t2.id, t2.name, date_format(t1.created,\'%W %M %e, %Y - %r\') In postresql no date_format function, we need to use to_char function but it still work because still need to put ::date such as SELECT to_char

Re: [SQL] surrogate key or not?

2004-07-21 Thread sad
Thnx, Josh (Byou are very helpful. (B (B> There are, in fact, three very good reasons to use surrogate keys, all of (B> which are strictly due to limitations of technology; that is, (B> implementation and performance issues, NOT business logic. They are: (B> (B> 1) Convenience: It's very a

Re: [SQL] surrogate key or not?

2004-07-21 Thread Markus Bertheau
Ð ÐÑÐ, 21.07.2004, Ð 09:44, sad ÐÐÑÐÑ: > 4) Replication: to identify an object of ANY type (record of any table > regardless to datamodel), to store lists of deleted or modified objects > (regardless to datamodel) That sounds like a datamodel on data that belongs to another data model, and 5)

Re: [SQL] surrogate key or not?

2004-07-21 Thread sad
On Wednesday 21 July 2004 14:58, Markus Bertheau wrote: > > 4) Replication: to identify an object of ANY type (record of any table > > regardless to datamodel), to store lists of deleted or modified objects > > (regardless to datamodel) > > That sounds like a datamodel on data that belongs to ano

Re: [SQL] Please help me.. problem in to_char

2004-07-21 Thread Markus Bertheau
Ð ÐÑÐ, 21.07.2004, Ð 10:33, azah azah ÐÐÑÐÑ: > Hi, > I want convert from mysql to postresql, previously > in mysql the code as below: > > SELECT t2.id, t2.name, date_format(t1.created,\'%W %M %e, %Y - %r\') > > In postresql no date_format function, we need to use to_char function > but it still

[SQL] ? on announcement of 7.5

2004-07-21 Thread sad
Hello can anyone comment the announcement of 7.5 about "nested transactions" ? doesn't the nesting hurt the matter of transaction ? ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Please help me.. problem in to_char

2004-07-21 Thread Theodore Petrosky
what kind of column is t1.created? It appears that it is a text column and the format looks like a date. Is this correct or is it a date? I need more information about your table structure. What about: SELECT t2.id, t2.name, to_char(cast (t1.created as date),'DD/MM/') but the other '::' sh

Re: [SQL] date_format in postresql

2004-07-21 Thread Frank Bax
Check your version with: select version(); In the meantime, you could try date_part('epoch', submittime) which will return a unix timestamp, you could then use functions within your scripting language to convert to human readable date formats. Frank At 11:53 PM 7/20/04, azah azah

[SQL] immutable function calling stable function

2004-07-21 Thread Markus Bertheau
Hi, shouldn't it be illegal for an immutable function to call a stable one? -- Markus Bertheau <[EMAIL PROTECTED]> ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EM

Re: [SQL] date_format in postresql

2004-07-21 Thread Rod Taylor
On Tue, 2004-07-20 at 23:53, azah azah wrote: > Thanks Chris and Rod. > > I think I have a problem because not many function existing in > postresql that i installed. > How can i get all the build-in functions because the basic function > to_char is not existing in the database? Which version of

Re: [SQL] immutable function calling stable function

2004-07-21 Thread Stephan Szabo
On Wed, 21 Jul 2004, Markus Bertheau wrote: > shouldn't it be illegal for an immutable function to call a stable one? It's expected that the function's creator is responsible for properly marking its stability. This allows some flexibility when you know more than the system does (for example, a

[SQL] MySQL-style "create temporary table foo select ..."

2004-07-21 Thread Geoff Richards
Hi, I've got some code that currently uses MySQL, and it copies an existing table into a temporary one like so: create temporary table tmp_foo select * from foo; That creates 'tmp_foo' with the same columns as 'foo', which is very convenient. I can't seem to find any reference to how to do t

Re: [SQL] immutable function calling stable function

2004-07-21 Thread Tom Lane
Markus Bertheau <[EMAIL PROTECTED]> writes: > shouldn't it be illegal for an immutable function to call a stable one? No, because that's the standard hack for getting around it when you wish to call a stable function in what you know to be a "safe" way. If you look in the archives you'll find cas

Re: [SQL] MySQL-style "create temporary table foo select ..."

2004-07-21 Thread Michael Kleiser
create temporary table tmp_foo AS select * from foo; Geoff Richards schrieb: Hi, I've got some code that currently uses MySQL, and it copies an existing table into a temporary one like so: create temporary table tmp_foo select * from foo; That creates 'tmp_foo' with the same columns as 'foo', wh

[SQL] Sorry too many conecctions

2004-07-21 Thread Javier Tesis Tolosa Trabajo
hi everybody I speak english a little,Sorry. I have A problem whith de connections from a Aplicatio Java, guive me a Error "Sorry too many clients",I think what is becuase I don't close connecction to the DB postgresql, I do aprox. 1000 conecction into statement "while" What can Do? thakns ___

Re: [SQL] surrogate key or not?

2004-07-21 Thread Rod Taylor
> All three of these implementation issues are, at least in theory, > surmountable. For example, Sybase overcame problems (1) and (3) by creating > an automated, system-controlled hash key based on the table's real key. This > was a solution endorsed by E.F. Codd in the mid-90's when he came

Re: [SQL] MySQL-style "create temporary table foo select ..."

2004-07-21 Thread Geoff Richards
On Wed, Jul 21, 2004 at 05:07:46PM +0200, Michael Kleiser wrote: > create temporary table tmp_foo AS select * from foo; Ah, that's a relief, thanks. Just what I need. Must have missed it in the create table syntax. > Geoff Richards schrieb: > >Hi, > > > >I've got some code that currently uses M

Re: [SQL] surrogate key or not?

2004-07-21 Thread Josh Berkus
Sad, (B (BFirst of all, please excuse me if I've misunderstood you below because of (Btranslation issues. You'll find I'm rather strident, but it's because the (Breasons you're presenting, or seem to be, are excuses for bad database design (BI hear every day on the job, and end up having

Re: [SQL] Sorry too many conecctions

2004-07-21 Thread Gregory S. Williamson
In the root directory in which postgres stores the data is a file: postgresql.conf Edit the file with a text editor (vi / ed / etc.) and change : max_connections = ### to max_connections = 1000 (or more since other applications or a DBA may need to connect as well) and also change shared_bu

Re: [SQL] ? on announcement of 7.5

2004-07-21 Thread Josh Berkus
Sad, > can anyone comment the announcement of 7.5 > about "nested transactions" ? > doesn't the nesting hurt the matter of transaction ? 7.5 hasn't been announced. It's not even in beta. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--

Re: [SQL] surrogate key or not?

2004-07-21 Thread Iain
Hi Josh, (B (BConsidering that I generally agree with your comments (in this and your (Blater posts) (BI'd say I didn't make myself clear in my brief comment. (B (BOf the considerations: performance, convenience and business logic, I (Bpersonally rate performance as the lowest priority. The

Re: [SQL] Please help me.. problem in to_char

2004-07-21 Thread azah azah
Why still not working??? I have try all the suggestions, still error like below: ERROR: cannot cast type character varying to date I'm using latest version of postresql. On Wed, 21 Jul 2004 05:35:06 -0700 (PDT), Theodore Petrosky <[EMAIL PROTECTED]> wrote: > > what kind of column is t1.created?

Re: [SQL] Please help me.. problem in to_char

2004-07-21 Thread azah azah
Thanks all, :) It working now, i'm using code as below: to_char(t1.created::date,'DD/MM/') but other problem come out, error as below: ERROR: relation "plugins" does not exist what that's mean?? table plugins already exists.. On Thu, 22 Jul 2004 10:43:35 +0800, azah azah <[EMAIL PROTECT

Re: [SQL] date_format in postresql

2004-07-21 Thread azah azah
Hi all, Successful solved. I'm just using to_timestamp function. Thanks On Wed, 21 Jul 2004 10:45:27 -0400, Rod Taylor <[EMAIL PROTECTED]> wrote: > On Tue, 2004-07-20 at 23:53, azah azah wrote: > > Thanks Chris and Rod. > > > > I think I have a problem because not many function existing in > > p

[SQL] next integer in serial key

2004-07-21 Thread Kenneth Gonsalves
hi, how does one get the next number in a serial type row? -- regards kg http://www.onlineindianhotels.net - hotel bookings reservations in over 4600 hotels in India http://www.ootygolfclub.org ---(end of broadcast)--- TIP 7: don't forget to incre

Re: [SQL] next integer in serial key

2004-07-21 Thread Oliver Elphick
On Thu, 2004-07-22 at 03:45, Kenneth Gonsalves wrote: > hi, > how does one get the next number in a serial type row? When inserting a new row, do not mention the serial column in the list of columns, or else give it the value DEFAULT. -- Oliver Elphick [E