Thread: pga3: SQL Formatting

pga3: SQL Formatting

From
"Dave Page"
Date:
Hi all,

I'm after some thoughts on SQL formatting for the SQL pane in pgAdmin 3,
not so much about how it's indented etc, but whether we include DROPs,
ALTER's etc.

For example, for a simple table we might have:

-- Table: public.foo
CREATE TABLE public.foo (
  bar INTEGER
);

or should we have:

-- Table: public.foo

DROP TABLE public.foo;

CREATE TABLE public.foo (
  bar INTEGER
);

or

-- Table: public.foo

-- DROP TABLE public.foo;

CREATE TABLE public.foo (
  bar INTEGER
);

In the case of an alter command, we could use something more like:

-- Check: bar_val

ALTER TABLE foo DROP CONSTRAINT bar_val;

ALTER TABLE foo
  ADD CONSTRAINT bar_val
  CHECK (bar > 100);

or a variant thereof.

Comments, thoughts? I'm leaning towards including both the DROP and
CREATE myself, without commenting out either.

Regards, Dave.


Re: pga3: SQL Formatting

From
Andreas Pflug
Date:
Dave Page wrote:

>I'm after some thoughts on SQL formatting for the SQL pane in pgAdmin 3,
>not so much about how it's indented etc, but whether we include DROPs,
>ALTER's etc.
>
>-- Table: public.foo
>
>-- DROP TABLE public.foo;
>
>CREATE TABLE public.foo (
>  bar INTEGER
>);
>
>
>Comments, thoughts? I'm leaning towards including both the DROP and
>CREATE myself, without commenting out either.
>
>
For my opinion, a "launch sql window" and F5 shouldn't do harm if
executed by mistake, thus the DROP should be commented out.
The SQL pane is a hint for designing own db schema scripts, showing how
objects are created. The drop is an additional tip how the syntax would
be to alter by command line. Thus the drop should stay commented out.
The SQL pane of the property dialogs will show the complete batch
executably.

Regards,
Andreas


Re: pga3: SQL Formatting

From
"Dave Page"
Date:

> -----Original Message-----
> From: Andreas Pflug [mailto:Andreas.Pflug@web.de]
> Sent: 09 May 2003 12:42
> To: Dave Page
> Subject: Re: [pgadmin-hackers] pga3: SQL Formatting
>
>
> For my opinion, a "launch sql window" and F5 shouldn't do harm if
> executed by mistake, thus the DROP should be commented out.

Actually I find this a bit annoying as I rarely want to execute SQL
that's anything like what I'm browsing. Perhaps we should have a 'Sticky
SQL' option, and leave the DROP commented out for those that want to
turn/leave it on?

Regards, Dave.