Database Reference
In-Depth Information
parenttable is the name of the table where the column resides.
We can add this to the CREATE definition for our log table as follows:
CREATE TABLE Log ( ID MEDIUMINT
NOT NULL
AUTO_INCREMENT
PRIMARY KEY,
CookieID MEDIUMINT,
WebpageID MEDIUMINT,
Browser VARCHAR(50),
DateCreated DATETIME,
IPNumber VARCHAR(15),
ReferringPage VARCHAR(255),
FOREIGN KEY (WebpageID ) REFERENCES Webpage (ID),
FOREIGN KEY (CookieID ) REFERENCES Cookies (CookieID)
)
TYPE = InnoDB
Figure 4.10 shows this table being described.
If you try to create this table after you have run the previous script you will get a Ta b l e
already exists error. You can add the words:
IF NOT EXISTS
directly after the:
CREATE TABLE
statement to stop MySQL generating an error; however this does not replace the table, it
just suppresses the error if it already exists, so it is of questionable use. Other versions of
Figure 4.10
DESCRIBE Log table.
Search WWH ::




Custom Search