0

I am using sqlite db in android.
In this I need to give Id as autoincrement and second 'Incoming_sms' field as primary key. but it shows me error as below:

detailMessage "near "AUTOINCREMENT": syntax error:  
CREATE TABLE TwoWayTable111 (
  ID INTEGER AUTOINCREMENT,  
  INCONMING_MSG TEXT PRIMARY KEY,  
  OUTGOING_MSG TEXT,  
  STATUS TEXT )" 

Why does this error occur? But when I give id as autoincrement and primary key, it works fine.

1 Answer 1

1

This is a FAQ. It works as designed. This statement returns a syntax error.

create table test (id integer autoincrement);

This one runs without error.

create table test (id integer primary key autoincrement);

You should be able to do this.

CREATE TABLE TwoWayTable111 (
    ID INTEGER PRIMARY KEY, 
    INCONMING_MSG TEXT NOT NULL UNIQUE, 
    OUTGOING_MSG TEXT, 
    STATUS TEXT );
Sign up to request clarification or add additional context in comments.

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.