James and Lawrence, Thank you both for opening my eyes a little wider. The idea of substituting a sorted view for my main table is very appealing. I believe a single-table view will behave exactly like the raw data table, allowing me to create forms and reports, enter/edit data, and, frankly, to omit an ORDER BY in many circumstances. I just need to wrap my own mind around it and convince my client that the entire concept is transparent. I particularly like the idea that I will NEVER have to think about it again. Yaay. I'm really glad I asked.
It's still good to know how to issue keys/indexes from the command line, though I believe that the view is my solution. Thanks, Fred Fred C. Kopp Authorized R:Base Developer 19 Teri Lane Washington, PA 15301 P 724-222-7376 F 724-222-7376 C 724-413-5534 E [EMAIL PROTECTED] ----- Original Message ----- From: "Lawrence Lustig" <[EMAIL PROTECTED]> To: "RBASE-L Mailing List" <[email protected]> Sent: Wednesday, February 06, 2008 8:58 PM Subject: [RBASE-L] - Re: Build PK from command file > <<I like to sort tables frequently (LastName,FirstName,etc.) so that we > don't always have to add an ORDER BY clause. Just lazy, I guess. This is > probably not great practice but... > > >> > > > > That's putting it mildly! > > > > If you always want the data sorted the same way, RBase offers an extension to > standard SQL that will let you do it and never have to worry about sorting > the data again. You can use ORDER BY with a view. To refactor an existing > database to keep the CUSTOMER table sorted automatically, do this: > > > > RENAME TABLE Customer TO Customer_Raw NOCHECK > > > > CREATE VIEW Customer AS SELECT * FROM Customer_Raw ORDER BY LastName, > FirstName > > > > You now have a fully editable single table view called Customer which looks > _exactly_ like the customer table but will always appear in name order. You > can insert, update, and delete from Customer as if it were a table, or you > can perform those actions directly on Customer_Raw, but Customer will always > give you the sorted customers. > > > > You'll take a slight performance hit for this, but not as big a hit as > constantly having to rebuild the table or missing records because they got > out of sequence. > > -- > > Larry > >

