Re: [SQL] Seeking quick way to clone a row, but give it a new pk.

2007-02-07 Thread Philip Hallstrom
I need to create some nearly identical copies of rows in a complicated table. Is there a handy syntax that would let me copy a existing row, but get a new primary key for the copy? I'd then go in an edit the 1 or 2 additional columns that differ. The duplicate would be in the same table as the

Re: [SQL] column names, types, properties for a table

2005-09-07 Thread Philip Hallstrom
Is it possible to issue an SQL query that lists column names, types (int, varchar, boolean, etc.), properties (like NOT NULL or UNIQUE) for a given table name ? Start psql with the -E option. Then "\d yourtable". It will print out the queries that are run internally to show you the table info

Re: [SQL] insert only if conditions are met?

2005-09-02 Thread Philip Hallstrom
At least I think that would do it. On 8/31/05, Philip Hallstrom <[EMAIL PROTECTED]> wrote: On Wed, 2005-08-31 at 12:49 -0400, Henry Ortega wrote: Ok. Here's TABLE A emp date hours type JSMITH 08-15-2005 5 WORK JSMITH 08-15-2005 3 WORK JSMITH 08-25-2005 6 WORK I want to in

Re: [SQL] insert only if conditions are met?

2005-08-31 Thread Philip Hallstrom
On Wed, 2005-08-31 at 12:49 -0400, Henry Ortega wrote: Ok. Here's TABLE A empdate hours type JSMITH 08-15-2005 5 WORK JSMITH 08-15-2005 3 WORK JSMITH 08-25-2005 6 WORK I want to insert the ff: 1.) JSMITH

Re: [SQL] default value for select?

2005-05-09 Thread Philip Hallstrom
I want to update a column in myTable. The value this column is set to depends on a nested select statement which sometimes returns 0 rows instead of 1. This is a problem since the column I'm trying to update is set to refuse nulls. Here's a sample: update myTable set myColumn = (Select altColum

Re: [SQL] pg_dump without data

2005-05-06 Thread Philip Hallstrom
how do i get a dump of a postgresql database without the data? % pg_dump --help pg_dump dumps a database as a text file or to other formats. Usage: pg_dump [OPTION]... [DBNAME] . -s, --schema-onlydump only the schema, no data -philip ---(end of broadcast

Re: [SQL] SQL formatter?

2002-09-25 Thread Philip Hallstrom
Looks to be windows based, but... http://www.techno-kitten.com/PBL_Peeper/Online_Manual/SQL_Formatter/sql_formatter.html first hit when searching on google for "sql formatter". there were a lot of other options... You might look at how some of those C code indenter's work. Seems like some of

Re: [SQL] Aggregate binary AND

2001-11-01 Thread Philip Hallstrom
This worked for us in 7.something (don't need it anymore, but it should still work). You'll want to create one for INT8, INT2, etc.. if you are going to use those as well... CREATE AGGREGATE aggr_bitand ( BASETYPE = INT4, SFUNC1 = int4and, STYPE1 = INT4); On Thu, 1 Nov 2001, James Orr wrote: >

Re: [SQL] PostgreSQL downloads

2001-10-01 Thread Philip Hallstrom
Hi - http://www.us.postgresql.org/sites.html has a whole list of them... On Mon, 1 Oct 2001, [iso-8859-1] Miguel González wrote: > Does anyone where there is a web site or ftp site where i can download the > latest release of PostgreSQL? I have been trying to use the > ftp://ftp.postgresql.org

Re: [SQL] Holiday Calculations?

2001-09-18 Thread Philip Hallstrom
Not that this is the best solution, but I read in a book (SQL for smarties I think) the following (maybe I'm wrong, but this is what I remember :) Create a holidays table. Put in all the holidays. Do the math yourself and just put them in there manually for the next 10 years or so (and then rem

[SQL] Re: drop table if exists

2001-07-03 Thread Philip Hallstrom
Just drop the table using "DROP TABLE mytable;" and ignore the error... I'm sure there are fancy ways of doing it by accessing system tables, but the above works for me. On Tue, 3 Jul 2001, Jason Watkins wrote: > How can I duplicate the behavior of: > > DROP TABLE IF EXISTS mytable; > > CREATE T

[SQL] Re: Bit Mapping operation

2001-06-12 Thread Philip Hallstrom
In 7.1 it's there... using the |(or) &(and), etc.. operators. In 7.0.3 it's not although can be added easily. example: test=> select 2 | 1; ?column? -- 3 (1 row) test=> select 2 & 1; ?column? -- 0 (1 row) test=> select 3 & 1; ?column? -- 1 (1

[SQL] Re: Auto incrementing an integer

2001-05-14 Thread Philip Hallstrom
Take a look at the SERIAL datatype as well as sequences (CREATE SEQUENCE, NEXTVAL, CURRVAL). good luck! On Mon, 14 May 2001, Sylte wrote: > How do I construct a datatype that autoincrement in postgreSQL? > > Thanks > Sylte > > > > > ---(end of broadcast)-

Re: [SQL] retrieving a serial number

2000-06-28 Thread Philip Hallstrom
There's probably a way to get that serial number. I think I remember reading that when you specify it as SERIAL, postgresql actually creates a separate sequence. If that's the case then you could do "SELECT currval('mysequence')" -- although I'm not sure what "mysequence" should be set to. The ot