Re: Altering Table - Adding Primary Key With References
From: Sietse Wijnker (sietse.wijnker_at_ATsw-software.nl)
Date: 09/02/04
- Previous message: Mikhail: "Re: Altering Table - Adding Primary Key With References"
- In reply to: Mikhail: "Re: Altering Table - Adding Primary Key With References"
- Next in thread: Dan Freeman: "Re: Altering Table - Adding Primary Key With References"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 2 Sep 2004 23:48:31 +0200
Hi Mikhail,
You are (and i was) overlooking some additional clauses of the CREATE TABLE
command.
<some clauses snipped out/>
CREATE TABLE | DBF TableName1 [NAME LongTableName] [FREE]
( FieldName1 FieldType [( nFieldWidth [, nPrecision] )] [NULL | NOT
NULL]
[, FieldName2 ... ]
[, PRIMARY KEY eExpression2 TAG TagName2]
[, FOREIGN KEY eExpression4 TAG TagName4 REFERENCES TableName3 [TAG
TagName5]])
the same goes for the ALTER TABLE command
<some clauses snipped out/>
ALTER TABLE TableName1
[ADD PRIMARY KEY eExpression3 [FOR lExpression4] TAG TagName2
[ADD FOREIGN KEY [eExpression5] [FOR lExpression6] TAG TagName4
REFERENCES TableName2 [TAG TagName5]]
Sample code:
Parent table testparent references testchild through use of the index on
tch_tpr_ifk (TAG tpr_ifk)
CREATE TABLE testParent (;
tpr_ipk_longerthan10 I AUTOINC, ;
tpr_cvalue C(10), ;
PRIMARY KEY tpr_ipk_longerthan10 TAG tpr_ipk)
CREATE TABLE testChild (;
tch_ipk I AUTOINC, ;
tch_tpr_ifk I, ;
tch_cvalue C(10), ;
PRIMARY KEY tch_ipk TAG tch_ipk, ;
FOREIGN KEY tch_tpr_ifk TAG tpr_ifk REFERENCES testParent TAG tpr_ipk )
Regards,
Sietse Wijnker
"Mikhail" <Mikhail@discussions.microsoft.com> wrote in message
news:EAAF4F42-E926-42BF-9463-1D07616070D3@microsoft.com...
> You don't understand me, may be because my english is not so good :-)
>
> In identity relashionship primary key from parent table migrate in child
> table as primary key.
>
> VFP:
>
> If in parent table field name for PK not longer 10 char's i can use
> following code:
>
> CREATE TABLE ChildTable ( ;
> ChildTablePrimaryKey I PRIMARY KEY REFERENCES ParentTable, ;
> ....
> )
> but if name of field is longer 10 char's a erro? "Tag Name is too long"
> is
> occured.
>
> In next example i can specify TAG for PRIMARY KEY but can't specify
> REFRENCE
>
> CREATE TABLE ChildTable ( ;
> ChildTablePrimaryKey I, ;
> ....
> PRIMARY KEY ChildTablePrimaryKey TAG ChildTabPK
> )
>
> In ALTER TABLE command works similarly.
>
- Previous message: Mikhail: "Re: Altering Table - Adding Primary Key With References"
- In reply to: Mikhail: "Re: Altering Table - Adding Primary Key With References"
- Next in thread: Dan Freeman: "Re: Altering Table - Adding Primary Key With References"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|