将注释放在createtable语句的中间

时间:2012-05-10 20:13:37

标签: php mysql

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

$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

2 个答案:

答案 0 :(得分: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 

Read more...

答案 1 :(得分: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