Autoincrement
#1

I want to have the ID field auto increment, but when I do it in CREATE TABLE (sqlite), the ID field dont show in the database?

pawn Код:
"CREATE TABLE IF NOT EXISTS `ACCOUNTS` (`ID int(11) PRIMARY KEY   AUTOINCREMENT`)");
Reply
#2

Код:
CREATE TABLE IF NOT EXISTS `accounts` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Reply
#3

That didn't work. Here is my whole Create Table

Код:
"CREATE TABLE IF NOT EXISTS `ACCOUNTS` (`IP`, `PASSWORD`, `CASH`, `NAME`, `ADMIN`, `DEV`, `HELPER`, `VIP`, `LEVEL`, `XPOS`, `YPOS`, `ZPOS`, `NUMBER`, `PTIME`, `BANNED`, `SEX`, `TUT`, `FACTION`, `FACLEVEL`, `FACRANK`, `PAYCHECK`, `PAYDAY`, `HOURS`, `JAILED`, `MASK`, `JOB`, `LICENSE`, `CARKEY`, `CARKEY2`, `CARKEY3`, `GUNLICENSE`, `ARRESTED`, `WALKIE`, `BANREASON`, `GASCAN`, `ID` int(11) NOT NULL AUTO_INCREMENT, `BANADMIN`, `BANDATE`, `SKIN`)");
Reply
#4

Did you ever minded that CREATE TABLE IF NOT EXISTS will only be executed when the table do not exists?

So, delete it and try again. Or in PhpMyAdmin you can just go to You Database > Your Table > Structure > Click in edit in the ID field, and make sure that A_I box is checked.
Reply
#5

For SQLite, do this:

pawn Код:
CREATE TABLE IF NOT EXISTS `ACCOUNTS` (`ID` INTEGER PRIMARY KEY AUTOINCREMENT)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)