var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Sort a table in a DB?
I have just a small question:
Can I sort a table in the DB in order to prevent the necessity of the ORDER BY statement in the SQL query?
And if yes - how?
Of course, and it's very simple.
Assume I want to have a table with reverse ordering on the id. You can just create a view on the original table:
CREATE VIEW v_session_reverse AS
SELECT * FROM t_session order by id desc
now, all your future queries can be done on the v_session_reverse, which acts as an ordinary table.
...and if I delete a tuple from the view - is this tuple then deleted in the table as well?
if the database allows you to delete a row from the view, then yes, you have indeed deleted the row from the table
a view is "virtual" and does not have any rows itself
by the way, boaconstrictor, your original question could be interpreted two ways
first, how to get ordered results without using an ORDER BY yourself -- the view fills that job nicely
however, you have not actually "avoided" the sort -- the ORDER BY is in the view and it does get executed when you use the view, unless you override it with a different ORDER BY