SQLite Question
#1

My registration/login/saving system is using SQLite. I have a small question that shouldn't be hard to fix but I just didn't know the fix lol.

Everything is working fine but when I add another variable that I want saved, I save the variable but it doesn't automatically add the column to the table. I save it as if there was that column because I thought it would automatically add it. How do I insert a new column into a table for a new variable? Thanks
Reply
#2

ALTER TABLE `<table name>` ADD COLUMN `<column name>` <type INTEGER/TEXT> <optional DEFAULT(value)>

example:
ALTER TABLE `users` ADD COLUMN `kills` INTEGER DEFAULT(0)

I recommend using slice's BUD for sqlite, it makes it a lot easier to use without having to worry about so much things.
In BUD you could just do BUD::VerifyColumn("kills", BUD::TYPE_NUMBER );
Reply
#3

Quote:
Originally Posted by cessil
Посмотреть сообщение
ALTER TABLE `<table name>` ADD COLUMN `<column name>` <type INTEGER/TEXT> <optional DEFAULT(value)>

example:
ALTER TABLE `users` ADD COLUMN `kills` INTEGER DEFAULT(0)

I recommend using slice's BUD for sqlite, it makes it a lot easier to use without having to worry about so much things.
In BUD you could just do BUD::VerifyColumn("kills", BUD::TYPE_NUMBER );
Thanks! Pretty good advice. I'll look into it!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)