1

I want to make a new table but it says my query is wrong, and I have no idea what's wrong with the query because I exported the database from SQLite Database browser. Here's the query,

CREATE TABLE sqlite_sequence(name,seq);

and it says

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'seq)' at line 1

and if i can create that table i wanna insert into that table with this,

INSERT INTO sqlite_sequence VALUES('objek',55);

I hope it wont do another error.

Please tell me your opinion.

7 Answers 7

3

The sqlite_sequence table gets generated automatically when you assign a data field of a table to autoincrement (e.g. _id integer primary key autoincrement)

It is impossible to create table called sqlite_sequence manually because "Table Name cannot begin with sqlite_ as the object name reserved for internal use: SQLITE_SEQUENCE"

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

Comments

2

The only missing on your DDL is that it lacks datatypes on the columns,

CREATE TABLE sqlite_sequence
(
    name VARCHAR(20),
    seq INT
);

UPDATE 1

Comments

0

You need to specify the data types for name and seq.

Try:

create table SQLITE_SEQUENCE ( name varchar(255), seq int );

Comments

0

define data type for fields(columns)

CREATE TABLE sqlite_sequence(name varchar(200),seq int(8));

Comments

0

Here is a normal create table command for reference:

CREATE TABLE demo (id integer NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE DEFAULT 0,name text);

And yeah there's no problem with the INSERT command.

Comments

0

You have to define data type after each table field Like this:

CREATE TABLE sqlite_sequence (
                name VARCHAR(45),   
                seq INT
              );

Comments

0

In SQLite, you cannot manually create sqlite_sequence table because sqlite_sequence table is reserved to create it with AUTOINCREMENT internally.

The doc says below:

SQLite keeps track of the largest ROWID using an internal table named "sqlite_sequence". The sqlite_sequence table is created and initialized automatically whenever a normal table that contains an AUTOINCREMENT column is created.

So, if you try to manually create sqlite_sequence table as shown below:

CREATE TABLE sqlite_sequence (
  name TEXT
);

Then, you get the error below:

Parse error: object name reserved for internal use: sqlite_sequence

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.