Fred,
Your present policy of trying to keep your table rows in a
certain sort sequence is contrary to SQL concepts. SQL states
that one should not assume any implied sequence for data stored
or retried from a table. Henc the presence of the ORDER BY
clause. As the RBase optimizer processes your request you
cannot assume it will retrieve the data in any particular
sequence especially where more than one table is involved.
When you need data in a particular sequence you should include
an ORDER BY phrase. If you often request data in a particular
sort sequence consider creating a multi-column index.
Note. When you create PRIMARY KEY, UNIQUE KEY, and FOREIGN KEY
items RBase automitacilly creates Indexes to maintain that
relationship. The syntax analyzer and the optimizer are aware
of thse indexes and will use them when appropriate.
In the basic question you asked about creating a PRIMARY KEY the
column must also have the NOT NULL attribute. To the best of my
knowledge when you PROJECT a table you do not carry over any
attributes such as NOT NULL or any PRIMARY/UNIQUE/FOREIGN Keys
or any INDEXES. You must reestablish all those items on the
projected table. Also, if your source table contains COMPUTED
columns in the PROJECTED table such computed columns will be
converted to regular columns and prohibit using UNLOAD/BACKUP
commands.
Since the projected table does not contain the NOT NULL
attribute when you try to add the PRIMARY KEY from the command
line you must incude it in the alter table command.
Try the following ALTER TABLE tablename ADD NOT NULL PRIMARY KEY
(colname)
To see this and other interesting command check out
www.rsyntax.com
Jim Bentley
--- Fred C Kopp <[EMAIL PROTECTED]> wrote:
> 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...
>
> From a command file I can RENAME a table to, say, TEMP (I
> learned the hard way to use NOCHECK to avoid messing up forms
> and reports based on that table). Then I can PROJECT
> <original table name> from TEMP USING * ORDER BY LastName
> FirstName. Then I can DROP TABLE TEMP.
>
> NOW, how do I build a PK for ColName from the command file?
> ALTER TABLE is part of it BUT it wants me to declare UNIQUE
> VALUE for ColName before it will build the key. I know it's
> in the syntax somewhere but I just can't find it. I think
> it's more than one command.
>
> This doesn't seem all that unusual a thing to do. Could
> someone please help me with the syntax? Or, is there a better
> way to get the same result? (There usually is). I'm also
> interested in how to build FK and index from a command file.
>
> I realize that RELOAD or PACK would be a good thing to do
> after swelling up the database.
>
> 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]
Jim Bentley
American Celiac Society
[EMAIL PROTECTED]
tel: 1-504-737-3293
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.
http://tools.search.yahoo.com/newsearch/category.php?category=shopping