2

我得到了这个创建表语句;

$sql = "CREATE TABLE TermsFinal(
    `seed`          INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `source`        varchar(100),
    `old_term`      varchar(255),
    `new_term`      varchar(100),
    `same_as`       varchar(100),
    `last_access`   datetime)";

有没有办法在此声明中添加评论,效果如下?

$sql = "CREATE TABLE TermsFinal(
    `seed`          INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `source`        varchar(100),    //sample value services.media
    `old_term`      varchar(255),    // something like  "services.media>category:perspective"
    `new_term`      varchar(100),    // something like "opinion"
    `same_as`       varchar(100),    // the seed id of another record or another  "old_term" from this table 
    `last_update`   datetime)";      // when the last update took place
4

2 回答 2

2

尝试遵循 SQL 注释语法,但要小心文本中的 "

$sql = "CREATE TABLE TermsFinal( 
    `seed`          INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    `source`        varchar(100),    -- sample value services.media 
    `old_term`      varchar(255),    -- something like  "services.media>category:perspective" 
    `new_term`      varchar(100),    -- something like "opinion" 
    `same_as`       varchar(100),    -- the seed id of another record or another  "old_term" from this table  
    `last_update`   datetime)";      // when the last update took place 

阅读更多...

于 2012-05-10T20:16:48.370 回答
1

您必须在您仍在 sql 语句中的行中使用 sql 注释。对于 mysql,这将是:

$sql = "CREATE TABLE TermsFinal(
`seed`          INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`source`        varchar(100),    /* sample value services.media */
`old_term`      varchar(255),    /* something like  "services.media>category:perspective" */
`new_term`      varchar(100),    /* something like "opinion" */
`same_as`       varchar(100),    /* the seed id of another record or another  "old_term" from this table */
`last_update`   datetime)";      // when the last update took place
于 2012-05-10T20:21:19.270 回答