0

There is the following script:

CREATE TABLE IF NOT EXISTS `location_cities` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `location_region_id` int(11) NOT NULL DEFAULT '0',
  `location_district_id` int(11) DEFAULT NULL,
  `location_country_id` int(11) NOT NULL DEFAULT '0',
  `lon` float(11,8) NOT NULL DEFAULT '0.00000000',
  `lat` float(11,8) NOT NULL DEFAULT '0.00000000',
  `prefix` varchar(50) DEFAULT NULL,
  `name` varchar(128) NOT NULL,
  `size` int(3) NOT NULL DEFAULT '0' COMMENT 'Размер города',
  `tz_name` varchar(128) DEFAULT NULL,
  `timezone` varchar(100) NOT NULL DEFAULT '+00:00',
  `timezone2` varchar(100) NOT NULL DEFAULT '+00:00',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=12393 ;

When I try to execute it using 'sqlite3 db/development.sqlite3 < alogist.sql' I got error 'Error: near line 27: near "AUTO_INCREMENT": syntax error' (27 - the line with "CREATE_TABLE ...". So, what's the trouble? How can I fix it? Thanks!

1
  • 1
    It's AUTOINCREMENT not 'AUTO_INCREMENT' . In SQLLite no AUTO_INCREMENT is there. Commented Sep 22, 2014 at 8:57

2 Answers 2

1

In sqlite, an autoincrement column is specified as

INTEGER PRIMARY KEY AUTOINCREMENT

Replace your int(11) NOT NULL AUTO_INCREMENT with that.

Further problems:

  • COMMENT is not supported. Remove COMMENT 'Размер города'

  • Remove PRIMARY KEY (ID) - the primary key has already been specified.

  • Remove the MySQL-specific ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12393.

Sign up to request clarification or add additional context in comments.

Comments

0

SQLite syntax:

 `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL

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.