mysql PHP自动增量列

时间:2011-01-15 15:29:31

标签: php mysql auto-increment

如何在这些语句中添加名为ID的自动递增列:

$sql = "CREATE TABLE IF NOT EXISTS ".$username." (uid varchar(255), tweet varchar(255))";
$alter = "ALTER TABLE ".$username." ADD UNIQUE (uid)";

由于

2 个答案:

答案 0 :(得分:1)

$sql = "CREATE TABLE IF NOT EXISTS ".$username." (ID int not null auto_increment primary key, uid varchar(255), tweet varchar(255))";

答案 1 :(得分:1)

我愿意

"CREATE TABLE IF NOT EXISTS ".$username." (id MEDIUMINT AUTO_INCREMENT PRIMARY KEY, uid varchar(255) UNIQUE, tweet varchar(255))";