Re: [SQL] randomized order in select?

2004-03-10 Thread Tom Lane
Bruno Wolff III <[EMAIL PROTECTED]> writes: > Enver ALTIN <[EMAIL PROTECTED]> wrote: >> I wish I could do something like: >> select tiptext from tips order by random limit 1 >> in PostgreSQL. > You can but it won't be very efficient (for large tables) as it will generate > a random ordering for

Re: [SQL] randomized order in select?

2004-03-10 Thread Iain
If you have a lot of tips, you could create a unique indexed tip number column. Select the highest tip number using: select tip_number from tips order by tip_number desc limit 1; Then generate a random number and select using that tip_number. Of course, you would have to allow for the possibilit

Re: [SQL] designer tool connect to PostgreSQL

2004-03-10 Thread azwa
Hi,   thanks to all for the responnd...i've look into all the tools mentioned and found many tools which has a great feautre such as designing/modelling the object/table but it seems look like that there is no tools that can do the ETL process. thanks in advance Rich Hall <[EMAIL PROTECTE

Re: [SQL] randomized order in select?

2004-03-10 Thread Enver ALTIN
On Wed, 2004-03-10 at 13:02 -0600, Bruno Wolff III wrote: > You can but it won't be very efficient (for large tables) as it will generate > a random ordering for the whole table, probably do a sort and then return the > first record. The only thing different you need to do is add () after random:

Re: [SQL] Converting query to view - duplicate fields - solved

2004-03-10 Thread Richard Grosse
At 02:17 10/03/2004, you wrote: On Tue, 9 Mar 2004, Richard Grosse wrote: > Trying to convert the query below to a view. The problem is > despite it working as a query when trying to save it as a > view the database returns the error that the field tablealias.cmpname > is duplicated. (Which it is

[SQL] About pg_dump

2004-03-10 Thread Daniel Henrique Alves Lima
Hi, everybody ! I don't know if this is the best list to ask this question but if it doesn't, please forgive me (should i try pgsl-general, maybe ?)... We have a postgresql database in production and i've 2 questions about pg_dumpall boring me. We "dump" both ddl and data as SQL command

Re: [SQL] Inserting data in a table using sub-selects]

2004-03-10 Thread Andreas Joseph Krogh
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wednesday 10 March 2004 21:56, Marty Scholes wrote: > INSERT INTO table2 (id, content) ( > SELECT id, coalesce(title, '') || ' ' || coalesce(description, '') > FROM table1 t1); > > If you want to keep them syncrhonized, in other words, rerun

Re: [SQL] Break a report in Run Time

2004-03-10 Thread Jonathan Gardner
On Wednesday 10 March 2004 10:23 am, Jander wrote: >I have a application with a lof of reports. I need to > break a report in Run Time. How can I do this? > Could you clarify what you mean by "break a report in run time"? -- Jonathan Gardner [EMAIL PROTECTED] ---

Re: [SQL] Changing primary keys

2004-03-10 Thread Jonathan Gardner
On Wednesday 10 March 2004 09:17 am, David wrote: > Is it possible to change the primary key of a relation? I want to add an > attribute, that i already have in the realtion, to the primary key (yes i > realise i designed my model pretty badly) > It sure is. First, ensure that the values are inde

[SQL] Break a Report in Run Time

2004-03-10 Thread Jander Rebelo Luiz
I have a apllication with a lot of reports, where I need to break a process report in run time. How Can I do this? Thanks. Jander. ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining col

Re: [SQL] Inserting data in a table using sub-selects]

2004-03-10 Thread Marty Scholes
INSERT INTO table2 (id, content) ( SELECT id, coalesce(title, '') || ' ' || coalesce(description, '') FROM table1 t1); If you want to keep them syncrhonized, in other words, rerun the query over and over again without having to truncate table2 first or deleting all of the rows, you can: INSER

Re: [SQL] Inserting data in a table using sub-selects

2004-03-10 Thread Stephan Szabo
On Wed, 10 Mar 2004, Andreas Joseph Krogh wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hi, I'd like to fill one table with the contents of another table. Mye schema > is like this: > > CREATE TABLE table1( > id serial NOT NULL PRIMARY KEY, > title varchar NOT NULL, > description v

[SQL] Tsearch2 question: getting histogram of the vector elements

2004-03-10 Thread Rajesh Kumar Mallah
Greetings! My original problem is to de duplicate a list of around 0.3 million company names. Since a company name can be potentially (mis)spelt in numerous ways exactmatch obviously wont work. To make the searches faster i am using tsearch. For each company name i want to search other compa

Re: [SQL] Alter table

2004-03-10 Thread scott.marlowe
On Wed, 10 Mar 2004, David wrote: > Ok another very newbie question. How can i change the data type a column can > accept? at the moment it will only take character(7) i want to change it to > varchar(30), but i cant figure how, ideas? While there are ways to tinker with the system catalogs to ch

Re: [SQL] designer tool connect to PostgreSQL

2004-03-10 Thread Robert Treat
take a look at http://techdocs.postgresql.org/guides/GUITools Robert Treat On Tue, 2004-03-09 at 02:53, BenLaKnet wrote: > > Rekall ... > http://www.totalrekall.co.uk/ > (commercial website) > http://www.rekallrevealed.org/

Re: [SQL] randomized order in select?

2004-03-10 Thread Bruno Wolff III
On Wed, Mar 10, 2004 at 18:48:17 +0200, Enver ALTIN <[EMAIL PROTECTED]> wrote: > > collect an ID list, choose one randomly and retrieve it. I wish I could > do something like: > > select tiptext from tips order by random limit 1 > > in PostgreSQL. You can but it won't be very efficient

Re: [SQL] randomized order in select?

2004-03-10 Thread scott.marlowe
On Wed, 10 Mar 2004, Enver ALTIN wrote: > Hi, > > I have got a simple table like this: > > create table tips ( > id integer primary key unique, > tiptext text > ); > > and, I've got a website where I'm willing to show these tips in a random > order. E

[SQL] randomized order in select?

2004-03-10 Thread Enver ALTIN
Hi, I have got a simple table like this: create table tips ( id integer primary key unique, tiptext text ); and, I've got a website where I'm willing to show these tips in a random order. Each visitor will get a randomly selected tip. So for now, I

[SQL] Changing primary keys

2004-03-10 Thread David
Is it possible to change the primary key of a relation? I want to add an attribute, that i already have in the realtion, to the primary key (yes i realise i designed my model pretty badly) ---(end of broadcast)--- TIP 7: don't forget to increase you

[SQL] Alter table

2004-03-10 Thread David
Ok another very newbie question. How can i change the data type a column can accept? at the moment it will only take character(7) i want to change it to varchar(30), but i cant figure how, ideas? Many thanks Dave ---(end of broadcast)--- TIP 8: exp

[SQL] Break a report in Run Time

2004-03-10 Thread Jander
     I have a application with a lof of reports. I need to break a report in Run Time. How can I do this?   Thanks.   Jander Rebelo LuizAnalista de SistemastecSOFT - Tecnologia em Sistemas[EMAIL PROTECTED]Fone - (48) 3025.2861

Re: [SQL] changing constraints

2004-03-10 Thread David
Cheers that worked fine, i guess its obvious im new to postgres (SQL in general!), oh well you have to learn somehow Dave > > Try something like (untested): > ALTER TABLE genus ADD CONSTRAINT valid_gender CHECK (gender IN > ('masculine','feminine')); > > > -- > Richard Huxton > Archonet Lt

Re: [SQL] changing constraints

2004-03-10 Thread Richard Huxton
On Wednesday 10 March 2004 12:27, David wrote: > I tried adding a constraint thus: > de4=> ALTER TABLE genus ADD CHECK(gender = 'masculine' || 'feminine'); > But get the msg: > ERROR: AlterTableAddConstraint: rejected due to CHECK constraint $2 > I cant see a $2 constraint so why am i getting the

Re: [SQL] changing constraints

2004-03-10 Thread Achilleus Mantzios
O kyrios David egrapse stis Mar 10, 2004 : > I tried adding a constraint thus: > de4=> ALTER TABLE genus ADD CHECK(gender = 'masculine' || 'feminine'); > But get the msg: > ERROR: AlterTableAddConstraint: rejected due to CHECK constraint $2 Which pgsql version are you using?? In any case what y

[SQL] changing constraints

2004-03-10 Thread David
I tried adding a constraint thus: de4=> ALTER TABLE genus ADD CHECK(gender = 'masculine' || 'feminine'); But get the msg: ERROR: AlterTableAddConstraint: rejected due to CHECK constraint $2 de4=> \d genus Table "public.genus" Column | Type | Modifiers ---