0

How do i add an auto incrementing column called ID to these statements:

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

Thanks

2 Answers 2

1

I would do

"CREATE TABLE IF NOT EXISTS ".$username." (id MEDIUMINT AUTO_INCREMENT PRIMARY KEY, uid varchar(255) UNIQUE, tweet varchar(255))";
Sign up to request clarification or add additional context in comments.

1 Comment

Why limiting the auto increment to 8 millions?
1
$sql = "CREATE TABLE IF NOT EXISTS ".$username." (ID int not null auto_increment primary key, uid varchar(255), tweet varchar(255))";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.