Im building and app with flutter that uses SQLite database. I have created first table using this piece of code:
void _createDb(Database db, int newVersion) async {
await db.execute('''CREATE TABLE cards (id_card INTEGER PRIMARY KEY,
color TEXT, type TEXT, rarity TEXT, name TEXT UNIQUE, goldCost INTEGER,
manaCost INTEGER, armor INTEGER, attack INTEGER, health INTEGER, description TEXT)''');
}
Table gets created and I can access it without problems.
Unfortunately I cannot include more than 1 table that i just created. I tried adding another SQL CREATE TABLE clause in the same method, and repeating method db.execute
with a different SQL clause just in the next line.
I'm mimicing code from this tutorial: https://www.youtube.com/watch?v=xke5_yGL0uk
How to add another table within the same database?
You can just combine multiple db.execute calls for exampple
await db.execute('''
create table $reminderTable (
$columnReminderId integer primary key autoincrement,
$columnReminderCarId integer not null,
$columnReminderName text not null,
$columnReminderNotifyMileage integer not null,
$columnReminderEndMileage integer not null
)''');
await db.execute('''
create table $carTable (
$columnCarId integer primary key autoincrement,
$columnCarTitle text not null
)''');