Jump to content

SQL. dbExec(AUTO_INCREMENT)


fairyoggy

Recommended Posts

  • Moderators

@slapz0r

Afaik that is the mysql syntax.

I can't remember what the syntax was for sql, but probably something like this:

https://www.queryexamples.com/sql/table/sql-create-table-with-primary-key-foreign-key-and-autoincrement/

 

Maybe:

`houseID` INT PRIMARY KEY AUTOINCREMENT

Or

`houseID` AUTOINCREMENT PRIMARY KEY

 

Hmmm, probably trying till you get it right. Still confusing all those different syntaxes...

 

And if that doesn't work out, then you can also manually fix it with a viewer:

https://sqlitebrowser.org/

(Stop the resource)

Edited by IIYAMA
  • Like 1
Link to comment
1 hour ago, IIYAMA said:

@slapz0r

Afaik that is the mysql syntax.

I can't remember what the syntax was for sql, but probably something like this:

https://www.queryexamples.com/sql/table/sql-create-table-with-primary-key-foreign-key-and-autoincrement/

 

Maybe:

`houseID` INT PRIMARY KEY AUTOINCREMENT

Or

`houseID` AUTOINCREMENT PRIMARY KEY

 

Hmmm, probably trying till you get it right. Still confusing all those different syntaxes...

 

And if that doesn't work out, then you can also manually fix it with a viewer:

https://sqlitebrowser.org/

(Stop the resource)

@IIYAMA

dbExec( dbSecurityConnection, ' CREATE TABLE if not exists `housing` (`houseID` INT PRIMARY KEY AUTOINCREMENT)' )

used this option, but got this error:

GohdrxwPjwY.jpg

Why? Indicated that it (INT PRIMARY KEY)

The second option throws an error with syntax.

 

Link to comment
  • 10 months later...
On 16/08/2019 at 09:49, slapztea said:

above

 

On 16/08/2019 at 18:59, IIYAMA said:

well

i know it's old but i was have same problem and wanna share the solution

first create table gonna be

'CREATE TABLE IF NOT EXISTS FullData ( id INTEGER PRIMARY KEY AUTOINCREMENT , dataName TEXT, Data TEXT)'

like this

and inserting gonna be like this

 "INSERT INTO FullData(dataName,Data) VALUES('Group' , 'test' )" 

 

there is another sol for lazy persons like me :D

 "INSERT INTO FullData VALUES(NULL,'Group' , 'test' )" 

 

hope it helps

Enjoy

Edited by Master_MTA
  • Like 2
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...