On Oct 23, 2008, at 3:40 PM, [EMAIL PROTECTED] wrote:

>
> hi
> i've no much idea about sql views, so i want to ask something.
> As i understand, views are sort-of virtual tables consisting of
> whatever a query structure may contain. So:
> 1) is it possible sql views to be created via SA in a more or less
> server-independent way? if issuing raw sql is the only way, any
> pointer how it is done in, say, sqlite, postgres, mssql?
> 2) once there, what can be done with them? are they a
> readonly "table"? can they have "foreign keys" i.e. relations to and
> from?
> 3) what is the advantage of a view vs issuing the ~same query over
> and over? i mean, if it's just faster, roughly how much - 2x,
> 10x, ..?


theres two flavors of view (at least)...materialized and non  
materialized.  a non-materialized view is not much different from just  
selecting from a select.   materialized actually replicates the data  
represented by the select into its own tablespace.   So materialized  
is far more performant but has replication-oriented issues.   A plain  
view can of course pre-generate a query plan but I dont know if that  
makes much difference in the grand scheme of things (since by  
selecting from it, that would affect the plan anyway).

As far as syntax, I'm not deeply familiar with the differences, I've  
only done them on Oracle.   I don't recall them being able to have  
their own foreign keys and such.   I do know that "writeable" views  
exist as well but I'm not sure of the details of that.

A DB agnostic View object that can issue CREATE VIEW would be pretty  
straightforward, it would be like v =  
View(my_select_statement).create(engine).



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to