Thread: CREATE VIEW form stored in database?

CREATE VIEW form stored in database?

From
Mario Splivalo
Date:
When I create a view, I like to define it like this (just representing
the form here):

CREATE VIEW vw_my_view
AS
SELECTt1.col1,t2.col2
FROMt1JOIN t2    ON t1.col1 = t2.col3
WHEREt2.col4 = 'bla'


But, when I extracit it from postgres, it's somehow stored like this:

CREATE VIEW vw_my_view
AS
SELECT    t1.col1, t2.col2
FROM    t1
JOIN    t2 ON t1.col1 = t2.col3
WHERE    t2.col4 = 'bla'

The later is much more hard to read, and when I need to change the view,
i get rash and stuff :)

Is there a way to tell postgres NOT to format the 'source code' of my
views?
Mike
-- 
Mario Splivalo
Mob-Art
mario.splivalo@mobart.hr

"I can do it quick, I can do it cheap, I can do it well. Pick any two."




Re: CREATE VIEW form stored in database?

From
Richard Huxton
Date:
Mario Splivalo wrote:
> When I create a view, I like to define it like this (just representing
> the form here):
[snip]
> But, when I extracit it from postgres, it's somehow stored like this:
[snip]
> The later is much more hard to read, and when I need to change the view,
> i get rash and stuff :)
> 
> Is there a way to tell postgres NOT to format the 'source code' of my
> views?

I don't think it stores the "source code", but rather the structure of 
the underlying query. So I'm afraid you lose the spacing.

I keep all my definitions in a set of files and read in updates with \i 
my_filename.sql from psql. That lets me keep all my spaces and comments.

--   Richard Huxton  Archonet Ltd


Re: CREATE VIEW form stored in database?

From
Mario Splivalo
Date:
On Tue, 2006-01-31 at 12:30 +0000, Richard Huxton wrote:
> Mario Splivalo wrote:
> > When I create a view, I like to define it like this (just representing
> > the form here):
> [snip]
> > But, when I extracit it from postgres, it's somehow stored like this:
> [snip]
> > The later is much more hard to read, and when I need to change the view,
> > i get rash and stuff :)
> > 
> > Is there a way to tell postgres NOT to format the 'source code' of my
> > views?
> 
> I don't think it stores the "source code", but rather the structure of 
> the underlying query. So I'm afraid you lose the spacing.
> 
> I keep all my definitions in a set of files and read in updates with \i 
> my_filename.sql from psql. That lets me keep all my spaces and comments.
> 

Yes, I'm tied to the pgadmin3 for the moment, so there's nothing I could
do. It's a pain to develop a database such way. 
Mike
-- 
Mario Splivalo
Mob-Art
mario.splivalo@mobart.hr

"I can do it quick, I can do it cheap, I can do it well. Pick any two."




Re: CREATE VIEW form stored in database?

From
George Weaver
Date:
----- Original Message ----- 
From: "Mario Splivalo" <mario.splivalo@mobart.hr>
>
> Yes, I'm tied to the pgadmin3 for the moment, so there's nothing I could
> do. It's a pain to develop a database such way.

Mario,

If you keep your definition in a script file, you can copy the script and 
paste it into pgAdmin's Execute Arbitrary SQL Queries window, and then 
execute the script from there.

Regards,
George





Re: CREATE VIEW form stored in database?

From
George Weaver
Date:
----- Original Message ----- 
From: "Mario Splivalo" <mario.splivalo@mobart.hr>

>> If you keep your definition in a script file, you can copy the script and
>> paste it into pgAdmin's Execute Arbitrary SQL Queries window, and then
>> execute the script from there.
>>
>
> It's still a pain. If I have two dozen views, it takes too much time :)

You also have the option of loading script files in the Execute Arbitray SQL 
Queries window (File > Open, etc.).  Thus you could put all your views into 
one script file, load the file, and then execute the query.

>
> Mario
> -- 
> Mario Splivalo
> Mob-Art
> mario.splivalo@mobart.hr
>
> "I can do it quick, I can do it cheap, I can do it well. Pick any two."
>
>
>