0

i'm trying to convert a MySql data base to Sqlite but i'm facing a problem with the unique constraint of primary key, here is my MySql table code:

 CREATE TABLE `table01` (
  `idtable1` INT(11) NOT NULL DEFAULT 0,
  `nom1` VARCHAR(50) NULL DEFAULT NULL,
  PRIMARY KEY (`idtable1` ASC),
  UNIQUE KEY `idtable1` (`idtable1` ASC)
) DEFAULT CHARSET=utf8 ENGINE=InnoDB;

and when i convert it using DBconvert for SQLite & MySql here is what i get:

CREATE TABLE table01 (
  idtable1  int PRIMARY KEY NOT NULL DEFAULT 0,
  nom1      varchar(50) DEFAULT NULL
);

CREATE UNIQUE INDEX idtable1
  ON table01
  (idtable1);

so when i read my data base, "using SQLite Maestro", SQLite Maestro fail to recognize the primary key's unique contraint.

4

1 回答 1

0

Possible reason may be SQLite's strange quirk: it is sensitive about the exact wording when it is about primary keys:

http://www.sqlite.org/lang_createtable.html#rowid

A PRIMARY KEY column only becomes an integer primary key if the declared type name is exactly "INTEGER". Other integer type names like "INT" or "BIGINT" or "SHORT INTEGER" or "UNSIGNED INTEGER" causes the primary key column to behave as an ordinary table column with integer affinity and a unique index, not as an alias for the rowid.

于 2012-07-06T10:48:53.007 回答