1

我正在尝试在 PHP 代码中创建一个表,以便在浏览器中打开以创建该表。我需要表中的一个不同的数组,并有正确的代码在 Oracle 中创建它:

CREATE TYPE ReportEntries_Type AS OBJECT
(Subject VARCHAR (500));
/

CREATE OR REPLACE TYPE ReportEntries_VA AS
VARRAY (12) OF ReportEntries_Type;
/

CREATE TABLE ReportDetails
(ReportID INTEGER NOT NULL UNIQUE,
StudentID INTEGER NOT NULL UNIQUE,
ReportEntries ReportEntries_VA,
DateLastModified DATE NOT NULL,
CONSTRAINT ReportDetails_PK PRIMARY KEY (ReportID, StudentID),
CONSTRAINT RDStudentIDSD FOREIGN KEY (StudentID)
REFERENCES StudentDetails (StudentID));

但是,当放置在 PHP 代码中并添加到 MySQL 数据库时,会出现错误消息。我正在使用的代码如下:

<?php
require "connect_to_mysql.php";

$sqlCommand = "CREATE TYPE ReportEntries_Type AS OBJECT

...cont. code from above...

REFERENCES StudentDetails (StudentID))";

if (mysql_query ($sqlCommand)) {
echo "The ReportDetails table has been created successfully!";
} else {
echo "There has been an error";
}
?>

甚至可能吗?提前谢谢了 :)

4

1 回答 1

1

不,这不可能,对不起:(

在 MySQL 中,我们通常使用带有逗号分隔值的 VARCHAR 或 TEXT 字段来执行此操作。我知道,这很烦人:)

于 2012-03-26T16:12:36.163 回答